---
title: "openemail imports"
description: "Every command in this namespace, with its arguments, flags and examples."
url: "https://openemail.uk/docs/cli/reference/imports"
area: "CLI"
category: "Reference"
---

# openemail imports

Every command in this namespace, with its arguments, flags and examples.

## Commands

### `openemail imports list`

List one page of mailbox imports

```bash
openemail imports list [flags]
```

Returns one page of the imports in the workspace, newest first. Each carries its status, the bytes read so far out of the total, and running counts of messages seen, imported, skipped as duplicates, left out by your options and not imported.

A key limited to particular addresses sees only imports into those addresses.

Add `--all` to walk every page: a table on a terminal, one JSON object per line when piped or with `--ndjson`, and one `{ items, hasMore, nextCursor }` document with `--json`. `--max <n>` stops after that many items.

- Scopes: `threads:read`.
- Needs a sign-in.
- Aliases: `ls`.

**Flags**

- `--address-id <value>`: Only imports into this address.
- `--limit <n>` (default `25`): Rows per page, a whole number from 1 to 100. The server defaults to 25.
- `--cursor <value>`: The `nextCursor` from the previous page, an import id. One that names no import this key can see is a 400 `invalid_cursor`.
- `--all`: Fetch every page and stream the items as they arrive.
- `--max <n>`: Stop after this many items. Implies `--all`.
- `--ndjson`: Print every item as one JSON object per line. Implies `--all`

**Examples**

```bash
openemail imports list
```

With optional flags

```bash
openemail imports list --limit 50
```

Walk every page and stop after 100 items

```bash
openemail imports list --all --max 100
```

One JSON object per line when piped

```bash
openemail imports list --all > imports.ndjson
```

Also available in: API [`GET /imports`](https://openemail.uk/docs/api/reference/imports#get-imports); SDK [`imports.list()`](https://openemail.uk/docs/sdk/reference/imports#list).

### `openemail imports get`

Read one mailbox import

```bash
openemail imports get <id> [flags]
```

Resolves one import with its status, byte progress and counts. Poll it while `status` is `queued` or `running`; it settles on `completed`, `failed` or `cancelled`.

An id from another workspace answers exactly like one that never existed, with 404.

- Scopes: `threads:read`.
- Needs a sign-in.
- Aliases: `show`, `view`.

**Arguments**

- `<id>` (required): Import id, `imp_` followed by 24 hex characters.

**Examples**

```bash
openemail imports get imp_3f9c2a7b1e4d8f60a5c7b92d
```

Print the raw JSON

```bash
openemail imports get imp_3f9c2a7b1e4d8f60a5c7b92d --json
```

Also available in: API [`GET /imports/{id}`](https://openemail.uk/docs/api/reference/imports#get-imports-id); SDK [`imports.get()`](https://openemail.uk/docs/sdk/reference/imports#get).

### `openemail imports create`

Create a mailbox import and get its upload plan

```bash
openemail imports create --address-id <value> --files <json|@file|-> [flags]
openemail imports create --data <json|@file|-> [flags]
```

Creates an import into one address of the workspace and returns it with `status: uploading`. Each file is uploaded in parts of `chunkBytes`, `files[i].chunks` of them, through `uploadChunk`, and `start` then queues the import.

The import reads Google Takeout archives, .mbox files from Apple Mail, Thunderbird and most desktop apps, .eml files, and .zip or .tgz archives holding any of those, up to 100 GB a file and 50 files an import. Threads, dates and labels come across. Imported mail is quiet: it runs no rules, forwards, notifications, summaries or webhooks.

`importFiles` does create, upload and start in one call.

- Scopes: `threads:write`.
- Needs a sign-in.
- Aliases: `new`, `add`.

**Flags**

- `--address-id <value>`: The address the mail belongs to. It must be an address this workspace owns and this key may act for. Required, here or in `--data`.
- `--files <json|@file|->`: Each file as `{ name, bytes }`, 1 to 50 of them, each at most 100 GB. JSON shaped as `Array<ImportFileDescriptor>`, inline or from a file with @path. Required, here or in `--data`.
- `--options-keep-inbox`: Default true: mail that was in the old inbox lands in Inbox with its unread state. False files everything under Archive.
- `--options-include-spam`: Default false.
- `--options-include-trash`: Default false.
- `--data <json|@file|->`: The whole `body` as JSON, inline, from a file with @path, or - for standard input. Flags override its keys.

**Examples**

```bash
openemail imports create --address-id addr_2b7e --files @files.json
```

Read the whole body from a JSON file

```bash
openemail imports create --data @import.json
```

Also available in: API [`POST /imports`](https://openemail.uk/docs/api/reference/imports#post-imports); SDK [`imports.create()`](https://openemail.uk/docs/sdk/reference/imports#create).

### `openemail imports upload-state`

See which parts of the upload have arrived

```bash
openemail imports upload-state <id> [flags]
```

For each file, the indexes of the parts already stored, so an interrupted upload sends only what is missing. Empty once the import has left the `uploading` state.

- Scopes: `threads:write`.
- Needs a sign-in.

**Arguments**

- `<id>` (required): Import id, `imp_` followed by 24 hex characters.

**Examples**

```bash
openemail imports upload-state imp_3f9c2a7b1e4d8f60a5c7b92d
```

Print the raw JSON

```bash
openemail imports upload-state imp_3f9c2a7b1e4d8f60a5c7b92d --json
```

Also available in: API [`GET /imports/{id}/upload`](https://openemail.uk/docs/api/reference/imports#get-imports-id-upload); SDK [`imports.uploadState()`](https://openemail.uk/docs/sdk/reference/imports#uploadState).

### `openemail imports upload-chunk`

Upload one part of an import file

```bash
openemail imports upload-chunk <id> <file> <chunk> <data> [flags]
```

Stores one part of file `file`: the bytes from `chunk * chunkBytes` up to the next part. Every part is exactly `chunkBytes` long except the last, and a part of the wrong length is 400 `bad_chunk`. Sending a part again replaces it, so a failed part can simply be retried.

- Scopes: `threads:write`.
- Needs a sign-in.

**Arguments**

- `<id>` (required): Import id, `imp_` followed by 24 hex characters.
- `<file>` (required): The file index, in the order given to `create`.
- `<chunk>` (required): The part index, from 0.
- `<data>` (required): The part as a `Blob`, `Uint8Array` or `ArrayBuffer`.

**Examples**

```bash
openemail imports upload-chunk imp_3f9c2a7b1e4d8f60a5c7b92d 1 1 ./photo.jpg
```

Print the raw JSON

```bash
openemail imports upload-chunk imp_3f9c2a7b1e4d8f60a5c7b92d 1 1 ./photo.jpg --json
```

Also available in: API [`PUT /imports/{id}/files/{file}/chunks/{chunk}`](https://openemail.uk/docs/api/reference/imports#put-imports-id-files-file-chunks-chunk); SDK [`imports.uploadChunk()`](https://openemail.uk/docs/sdk/reference/imports#uploadChunk).

### `openemail imports start`

Queue an import once its files are uploaded

```bash
openemail imports start <id> [flags]
```

Checks that every part of every file has arrived, recognises each file's format and queues the import. A file still missing parts is 412 `missing_chunks`, and a file that is not an archive or a mailbox is 400 `unsupported_file`. Calling it on an import that has already left `uploading` returns it unchanged.

- Scopes: `threads:write`.
- Needs a sign-in.

**Arguments**

- `<id>` (required): Import id, `imp_` followed by 24 hex characters.

**Examples**

```bash
openemail imports start imp_3f9c2a7b1e4d8f60a5c7b92d
```

Print the raw JSON

```bash
openemail imports start imp_3f9c2a7b1e4d8f60a5c7b92d --json
```

Also available in: API [`POST /imports/{id}/start`](https://openemail.uk/docs/api/reference/imports#post-imports-id-start); SDK [`imports.start()`](https://openemail.uk/docs/sdk/reference/imports#start).

### `openemail imports cancel`

Cancel a mailbox import

```bash
openemail imports cancel <id> [flags]
```

Stops an import at its next checkpoint. Mail already imported stays in the mailbox. A finished import is 409 `not_cancellable`.

- Scopes: `threads:write`.
- Needs a sign-in.
- Asks you to confirm.

**Arguments**

- `<id>` (required): Import id, `imp_` followed by 24 hex characters.

**Examples**

```bash
openemail imports cancel imp_3f9c2a7b1e4d8f60a5c7b92d
```

Skip the confirmation, for scripts

```bash
openemail imports cancel imp_3f9c2a7b1e4d8f60a5c7b92d --yes
```

Also available in: API [`POST /imports/{id}/cancel`](https://openemail.uk/docs/api/reference/imports#post-imports-id-cancel); SDK [`imports.cancel()`](https://openemail.uk/docs/sdk/reference/imports#cancel).

### `openemail imports list-failures`

List what an import could not bring across

```bash
openemail imports list-failures <id> [flags]
```

Each message or archive entry that did not come across, with the reason: `too-large` (over 50 MB), `unparseable`, `no-date`, `storage-error`, `unreadable-entry`, `encrypted-entry` or `archive-limit`. Page with `after`, passing the `nextCursor` of the previous page.

- Scopes: `threads:read`.
- Needs a sign-in.

**Arguments**

- `<id>` (required): Import id, `imp_` followed by 24 hex characters.

**Flags**

- `--after <n>`: The `nextCursor` of the previous page.
- `--limit <n>`: At most 100, the default.

**Examples**

```bash
openemail imports list-failures imp_3f9c2a7b1e4d8f60a5c7b92d
```

Print the raw JSON

```bash
openemail imports list-failures imp_3f9c2a7b1e4d8f60a5c7b92d --json
```

Also available in: API [`GET /imports/{id}/failures`](https://openemail.uk/docs/api/reference/imports#get-imports-id-failures); SDK [`imports.listFailures()`](https://openemail.uk/docs/sdk/reference/imports#listFailures).

### `openemail imports delete-upload`

Delete the files uploaded for an import

```bash
openemail imports delete-upload <id> [flags]
```

Removes the uploaded archive. Mail already imported stays in the mailbox. An import still uploading is cancelled at the same time, and one that is queued or running is 409 `still_running`.

- Scopes: `threads:write`.
- Needs a sign-in.
- Asks you to confirm.

**Arguments**

- `<id>` (required): Import id, `imp_` followed by 24 hex characters.

**Examples**

```bash
openemail imports delete-upload imp_3f9c2a7b1e4d8f60a5c7b92d
```

Skip the confirmation, for scripts

```bash
openemail imports delete-upload imp_3f9c2a7b1e4d8f60a5c7b92d --yes
```

Also available in: API [`DELETE /imports/{id}/upload`](https://openemail.uk/docs/api/reference/imports#delete-imports-id-upload); SDK [`imports.deleteUpload()`](https://openemail.uk/docs/sdk/reference/imports#deleteUpload).

### `openemail imports import-files`

Create, upload and start an import in one call

```bash
openemail imports import-files --address-id <value> --files <path> [flags]
openemail imports import-files --data <json|@file|-> [flags]
```

Creates the import, uploads every file part by part and starts it, reporting progress through `onProgress`. Pass each file as a `Blob`, `Uint8Array` or `ArrayBuffer`; parts are sliced from it, so a `Blob` backed by a file on disk is never read into memory at once.

It resolves once the import is queued. Poll `get` to follow it.

- Scopes: `threads:write`.
- Needs a sign-in.

**Flags**

- `--address-id <value>`: The address the mail belongs to. Required, here or in `--data`.
- `--files <path>` (repeatable): Each file as `{ name, data }`. Required, here or in `--data`.
- `--options <json|@file|->`: `keepInbox`, `includeSpam` and `includeTrash`, as for `create`. JSON shaped as `ImportOptions`, inline or from a file with @path.
- `--data <json|@file|->`: The whole `input` as JSON, inline, from a file with @path, or - for standard input. Flags override its keys.

**Examples**

```bash
openemail imports import-files --address-id addr_2b7e --files ./takeout.zip
```

Read the whole body from a JSON file

```bash
openemail imports import-files --data @import.json
```

Also available in: API [`POST /imports`](https://openemail.uk/docs/api/reference/imports#post-imports); SDK [`imports.importFiles()`](https://openemail.uk/docs/sdk/reference/imports#importFiles).
