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

# nextmail provider-imports

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

## Commands

### `nextmail provider-imports inspect`

Look inside an account at another provider before importing

```bash
nextmail provider-imports inspect <api-key> [flags]
```

Reads the first page of every resource with a key from Resend, SendGrid, Postmark, Mailgun or Mailchimp and returns a count for each, with `more` set where a resource runs past its first page. `resources` lists what this key can bring across: what the provider has no such thing for, or the key may not read, is left out. Nothing is stored, and the key is not kept.

`--provider` picks the provider and defaults to `resend`. Resend needs a full-access key, SendGrid a key with read access, Postmark a Server API token, Mailgun a private API key from either region and Mailchimp an API key with its datacenter suffix. A key that can read nothing but sending is 400 `restricted_key`: create one with more access for the import and revoke it afterwards.

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

**Arguments**

- `<api-key>` (required): The key from the other provider: a full-access Resend key `re_…`, a SendGrid key `SG.…`, a Postmark Server API token, a Mailgun private API key or a Mailchimp key ending in its datacenter, such as `-us6`. Pass - to read it from standard input, or @path to read it from a file, so it stays out of your shell history.

**Flags**

- `--provider <value>`: One of `resend`, `sendgrid`, `postmark`, `mailgun` and `mailchimp`. Defaults to `resend`.

**Examples**

The required values only

```bash
nextmail provider-imports inspect @provider-key.txt
```

With optional flags

```bash
nextmail provider-imports inspect @provider-key.txt --provider sendgrid
```

Also available in: API [`POST /provider-imports/inspect`](https://nextmail.sh/docs/api/reference/imports#post-provider-imports-inspect); TypeScript [`nextmail.providerImports.inspect()`](https://nextmail.sh/docs/sdk/reference/provider-imports#inspect); Python [`provider_imports.inspect()`](https://nextmail.sh/docs/python/reference/provider-imports#inspect); Ruby [`provider_imports.inspect`](https://nextmail.sh/docs/ruby/reference/provider-imports#inspect); PHP [`providerImports->inspect`](https://nextmail.sh/docs/php/reference/provider-imports#inspect); Go [`ProviderImports.Inspect`](https://nextmail.sh/docs/go/reference/provider-imports#inspect); Java [`providerImports().inspect`](https://nextmail.sh/docs/java/reference/provider-imports#inspect); C# [`ProviderImports.InspectAsync`](https://nextmail.sh/docs/csharp/reference/provider-imports#inspect).

### `nextmail provider-imports create`

Import from another provider

```bash
nextmail provider-imports create --provider-key <value> --resources <a,b> [flags]
nextmail provider-imports create --data <json|@file|-> [flags]
```

Queues an import from Resend, SendGrid, Postmark, Mailgun or Mailchimp. Suppressions keep their reason, segments and lists become audiences, subscribed contacts arrive with their names, templates arrive as HTML templates with their variables declared, and webhooks are registered switched off because deliveries here are signed differently. A contact who unsubscribed at the provider is not imported and is recorded as unsubscribed, so `suppressions.listUnsubscribes` lists them. Domains and API keys come back as a checklist in the report, since a signing key or a token cannot leave the provider that made it. Resources the provider has no such thing for, or the key cannot read, are left out, and `resources` on the import says what it brings.

The key is held encrypted only while the import runs and is erased when it ends, fails or is cancelled. Running it twice duplicates nothing.

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

**Flags**

- `--provider-key <value>`: The key from the other provider, as `inspect` takes it. Pass - to read it from standard input, or @path to read it from a file, so it stays out of your shell history. Required, here or in `--data`.
- `--provider <value>` (default `"resend"`): One of `resend`, `sendgrid`, `postmark`, `mailgun` and `mailchimp`. Defaults to `resend`.
- `--resources <a,b>` (repeatable): Any of `suppressions`, `audiences`, `contacts`, `templates`, `webhooks`, `domains` and `api-keys`. Required, here or in `--data`.
- `--data <json|@file|->`: The whole `body` as JSON, inline, from a file with @path, or - for standard input. Flags override its keys.

**Examples**

The required values only

```bash
nextmail provider-imports create --provider-key @provider-key.txt --resources suppressions,audiences,contacts,templates,webhooks,domains,api-keys
```

With optional flags

```bash
nextmail provider-imports create --provider-key @provider-key.txt --resources suppressions,audiences,contacts,templates,webhooks,domains,api-keys --provider mailgun
```

Read the whole body from a JSON file

```bash
nextmail provider-imports create --data @provider-import.json
```

Also available in: API [`POST /provider-imports`](https://nextmail.sh/docs/api/reference/imports#post-provider-imports); TypeScript [`nextmail.providerImports.create()`](https://nextmail.sh/docs/sdk/reference/provider-imports#create); Python [`provider_imports.create()`](https://nextmail.sh/docs/python/reference/provider-imports#create); Ruby [`provider_imports.create`](https://nextmail.sh/docs/ruby/reference/provider-imports#create); PHP [`providerImports->create`](https://nextmail.sh/docs/php/reference/provider-imports#create); Go [`ProviderImports.Create`](https://nextmail.sh/docs/go/reference/provider-imports#create); Java [`providerImports().create`](https://nextmail.sh/docs/java/reference/provider-imports#create); C# [`ProviderImports.CreateAsync`](https://nextmail.sh/docs/csharp/reference/provider-imports#create).

### `nextmail provider-imports list`

List one page of imports from sending providers

```bash
nextmail provider-imports list [flags]
```

One page of the provider imports in the workspace, newest first, each with its report.

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: `settings:read`.
- Needs a sign-in.
- Aliases: `ls`.

**Flags**

- `--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. One that names no provider import in the workspace 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
nextmail provider-imports list
```

Walk every page and stop after 100 items

```bash
nextmail provider-imports list --all --max 100
```

One JSON object per line when piped

```bash
nextmail provider-imports list --all > provider-imports.ndjson
```

Also available in: API [`GET /provider-imports`](https://nextmail.sh/docs/api/reference/imports#get-provider-imports); TypeScript [`nextmail.providerImports.list()`](https://nextmail.sh/docs/sdk/reference/provider-imports#list); Python [`provider_imports.list()`](https://nextmail.sh/docs/python/reference/provider-imports#list); Ruby [`provider_imports.list`](https://nextmail.sh/docs/ruby/reference/provider-imports#list); PHP [`providerImports->list`](https://nextmail.sh/docs/php/reference/provider-imports#list); Go [`ProviderImports.List`](https://nextmail.sh/docs/go/reference/provider-imports#list); Java [`providerImports().list`](https://nextmail.sh/docs/java/reference/provider-imports#list); C# [`ProviderImports.ListAsync`](https://nextmail.sh/docs/csharp/reference/provider-imports#list).

### `nextmail provider-imports get`

Read one import from a sending provider

```bash
nextmail provider-imports get <id> [flags]
```

Status, the step it is on and the report so far. Poll it while `status` is `queued` or `running`.

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

**Arguments**

- `<id>` (required): Provider import id, `pimp_` followed by 24 hex characters.

**Examples**

```bash
nextmail provider-imports get pimp_3f9c2a7b1e4d8f60a5c7b92d
```

Print the raw JSON

```bash
nextmail provider-imports get pimp_3f9c2a7b1e4d8f60a5c7b92d --json
```

Also available in: API [`GET /provider-imports/{id}`](https://nextmail.sh/docs/api/reference/imports#get-provider-imports-id); TypeScript [`nextmail.providerImports.get()`](https://nextmail.sh/docs/sdk/reference/provider-imports#get); Python [`provider_imports.get()`](https://nextmail.sh/docs/python/reference/provider-imports#get); Ruby [`provider_imports.get`](https://nextmail.sh/docs/ruby/reference/provider-imports#get); PHP [`providerImports->get`](https://nextmail.sh/docs/php/reference/provider-imports#get); Go [`ProviderImports.Get`](https://nextmail.sh/docs/go/reference/provider-imports#get); Java [`providerImports().get`](https://nextmail.sh/docs/java/reference/provider-imports#get); C# [`ProviderImports.GetAsync`](https://nextmail.sh/docs/csharp/reference/provider-imports#get).

### `nextmail provider-imports cancel`

Cancel an import from a sending provider

```bash
nextmail provider-imports cancel <id> [flags]
```

Stops the import and erases the provider key. What already came across stays.

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

**Arguments**

- `<id>` (required): Provider import id, `pimp_` followed by 24 hex characters.

**Examples**

```bash
nextmail provider-imports cancel pimp_3f9c2a7b1e4d8f60a5c7b92d
```

Skip the confirmation, for scripts

```bash
nextmail provider-imports cancel pimp_3f9c2a7b1e4d8f60a5c7b92d --yes
```

Also available in: API [`POST /provider-imports/{id}/cancel`](https://nextmail.sh/docs/api/reference/imports#post-provider-imports-id-cancel); TypeScript [`nextmail.providerImports.cancel()`](https://nextmail.sh/docs/sdk/reference/provider-imports#cancel); Python [`provider_imports.cancel()`](https://nextmail.sh/docs/python/reference/provider-imports#cancel); Ruby [`provider_imports.cancel`](https://nextmail.sh/docs/ruby/reference/provider-imports#cancel); PHP [`providerImports->cancel`](https://nextmail.sh/docs/php/reference/provider-imports#cancel); Go [`ProviderImports.Cancel`](https://nextmail.sh/docs/go/reference/provider-imports#cancel); Java [`providerImports().cancel`](https://nextmail.sh/docs/java/reference/provider-imports#cancel); C# [`ProviderImports.CancelAsync`](https://nextmail.sh/docs/csharp/reference/provider-imports#cancel).
