# Dry run an import

```http
POST https://trydimmi.com/api/v1/imports/{import}/previews
```

## Authorization

Send an API token as `Authorization: Bearer <token>`.
The token needs: `contacts:write`.

## Path parameters

- `import` (string, required): Id of the import, starting with imp_, such as imp_01jx2m8k4t. Find it with GET /imports.

## Body

- `mapping` (object[] | null, required): A list of {column, field}: column is the index in the header from 0; field is email, name, external_id, phone, company_name, company_domain or tags for contacts, name, domain, external_id or tags for companies, or attribute.<key>. For the real run, send the same mapping as the dry run.
  - `column` (integer, required): Which column of the uploaded file this is, counted in the header from 0, so the first column is 0. It must be a column the file has, such as 2.
  - `field` (string, required): The field the column fills: email, name, external_id, phone, company_name, company_domain or tags for contacts; name, domain, external_id or tags for companies; or attribute.<key> for a custom attribute, such as attribute.plan.
- `mode` (string, required): What happens to records already there: update changes them, skip leaves them alone. Such as "skip". One of: `update`, `skip`.

## Response 200 (OK)

- `data` (object, required)
  - `created` (integer, required): How many records the dry run would create.
  - `errors` (object[] | null, required): The rows the dry run found would fail, each with its line in the file and why.
    - `message` (string, required): Why the row could not be imported, in plain words.
    - `row` (integer, required): Line of the file the failed row is on.
  - `failed` (integer, required): How many rows the dry run found would fail.
  - `object` (string, required): The kind of record this is, the same for every record of its kind, such as article.
  - `rows` (integer, required): How many rows the dry run read.
  - `skipped` (integer, required): How many rows the dry run would skip.
  - `updated` (integer, required): How many existing records the dry run would change.

## Response default (Error)

- `code` (string, required): Stable code for programs to tell errors apart, such as validation_failed or internal_error.
- `errors` (object): Each rejected field mapped to its messages. Only present when the input was invalid.
- `message` (string, required): What went wrong, in words safe to show a person.

## Example request

```bash
curl --request POST \
  --url 'https://trydimmi.com/api/v1/imports/{import}/previews' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "mapping": [
    {
      "column": 123,
      "field": "<string>"
    }
  ],
  "mode": "update"
}'
```

## Example response

```json
{
  "data": {
    "created": 123,
    "errors": [
      {
        "message": "<string>",
        "row": 123
      }
    ],
    "failed": 123,
    "object": "<string>",
    "rows": 123,
    "skipped": 123,
    "updated": 123
  }
}
```

---

Index of all dimmi docs: https://trydimmi.com/llms.txt (full text: https://trydimmi.com/llms-full.txt)
