# Imports

Copy a mailbox’s email over from a Google account.

An SDK signs every request with your key: [Authentication](https://mailset.app/docs/authentication.md). To sign one yourself, see [Calling the API without an SDK](https://mailset.app/docs/authentication/http.md).

## imports.start

Copy a mailbox’s mail from a Google account: opens Google to connect.

`POST /v1/imports.start`

An admin or owner of the org.

### Parameters

- `mailbox` (string, required): The mailbox the mail is copied into.
- `addresses` (array of strings, optional): Which of the mailbox’s addresses. Leave out for all of them. At most 100 items.

Beside `input`:

- `org` (string, optional): The org this is about. Needed when the caller is in more than one.

### Returns

`data` is an object with:

- `id` (string): The import’s id.
- `url` (string): Google’s page to open, to connect the account.

### Request

TypeScript:

```typescript
import { Mailset } from 'mailset';

// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();

const answer = await mailset.imports.start({
	mailbox: "ana@example.com",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()

answer = mailset.imports.start(
    {"mailbox": "ana@example.com"}
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.ImportsStartParams{
		Mailbox: "ana@example.com",
	}
	answer, err := client.Imports.Start(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.imports.start(mailbox: 'ana@example.com')
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();

$answer = $mailset->imports->start([
    'mailbox' => 'ana@example.com',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.ImportsStartParams;
import app.mailset.model.ImportsStartResult;

// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();

var params = ImportsStartParams.builder()
        .mailbox("ana@example.com")
        .build();
ImportsStartResult answer =
        mailset.imports().start(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::ImportsStartParams;

// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset
    .imports()
    .start(ImportsStartParams {
        mailbox: "ana@example.com".into(),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/imports.start \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"mailbox":"ana@example.com"},"org":"org_3f9a1c0e7b2d"}'
```

curl can’t sign a request. `$TOKEN` is your credential’s token, and `$MS_TIME` and `$MS_PROOF` sign this exact body: [Calling the API without an SDK](https://mailset.app/docs/authentication/http) shows how.

CLI:

```bash
mailset imports start ana@example.com
```

### Response

```json
{
  "ok": true,
  "data": {
    "id": "out_3f9a1c0e7b2d",
    "url": "https://hooks.example.com/mailset"
  }
}
```

In the CLI: [mailset reference](https://mailset.app/docs/cli/imports#imports-start)

## imports.list

List Gmail imports.

`POST /v1/imports.list`

An admin or owner of the org.

### Parameters

It takes no input: send an empty object.

Beside `input`:

- `org` (string, optional): The org this is about. Needed when the caller is in more than one.

### Returns

`data` is a list of objects, each with:

- `id` (string): The import’s id.
- `mailbox` (string): The mailbox the mail is copied into.
- `addresses` (array of strings): The addresses whose mail is copied: the mailbox’s own and its aliases.
- `account` (nullable string): The Google account it copies from, once connected.
- `state` (enum): How far along it is. One of `connecting`, `listing`, `copying`, `done`, `failed`, `cancelled`.
- `total` (number): Messages found so far.
- `imported` (number): Messages copied so far.
- `skipped` (number): Messages left out so far.
- `reason` (nullable string): Why it failed, when it did.
- `paused` (boolean): It is waiting because the org’s plan ended. It carries on once the plan is live again.
- `createdAt` (number): When it started, in milliseconds since 1970.
- `finishedAt` (nullable number): When it finished, in milliseconds since 1970, or null while it runs.

### Request

TypeScript:

```typescript
import { Mailset } from 'mailset';

// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();

const answer = await mailset.imports.list();
console.log(answer);
```

Python:

```python
from mailset import Mailset

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()

answer = mailset.imports.list()
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	answer, err := client.Imports.List(ctx)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.imports.list
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();

$answer = $mailset->imports->list();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.Import;
import java.util.List;

// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();

List<Import> answer = mailset.imports().list();
System.out.println(answer);
```

Rust:

```rust
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset.imports().list().await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/imports.list \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{},"org":"org_3f9a1c0e7b2d"}'
```

curl can’t sign a request. `$TOKEN` is your credential’s token, and `$MS_TIME` and `$MS_PROOF` sign this exact body: [Calling the API without an SDK](https://mailset.app/docs/authentication/http) shows how.

CLI:

```bash
mailset imports list
```

### Response

```json
{
  "ok": true,
  "data": [
    {
      "id": "out_3f9a1c0e7b2d",
      "mailbox": "text",
      "addresses": [
        "text"
      ],
      "account": "text",
      "state": "connecting",
      "total": 12,
      "imported": 1,
      "skipped": 1,
      "reason": "The day’s sending limit is reached.",
      "paused": true,
      "createdAt": 1796048940000,
      "finishedAt": 1796048940000
    }
  ]
}
```

In the CLI: [mailset reference](https://mailset.app/docs/cli/imports#imports-list)

## imports.cancel

Stop an import and end its access to Google.

`POST /v1/imports.cancel`

An admin or owner of the org.

### Parameters

- `id` (string, required): The import’s id, from `imports list`.

Beside `input`:

- `org` (string, optional): The org this is about. Needed when the caller is in more than one.

### Returns

`data` is an object with:

- `cancelled` (boolean)

### Request

TypeScript:

```typescript
import { Mailset } from 'mailset';

// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();

const answer = await mailset.imports.cancel({
	id: "imp_8d3b7e1a5c9f2046b2e7a1c5",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()

answer = mailset.imports.cancel(
    {"id": "imp_8d3b7e1a5c9f2046b2e7a1c5"}
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.ImportsCancelParams{
		ID: "imp_8d3b7e1a5c9f2046b2e7a1c5",
	}
	answer, err := client.Imports.Cancel(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.imports.cancel(
  id: 'imp_8d3b7e1a5c9f2046b2e7a1c5'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();

$answer = $mailset->imports->cancel([
    'id' => 'imp_8d3b7e1a5c9f2046b2e7a1c5',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.ImportsCancelParams;
import app.mailset.model.ImportsCancelResult;

// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();

var params = ImportsCancelParams.builder()
        .id("imp_8d3b7e1a5c9f2046b2e7a1c5")
        .build();
ImportsCancelResult answer =
        mailset.imports().cancel(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::ImportsCancelParams;

// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset
    .imports()
    .cancel(ImportsCancelParams {
        id: "imp_8d3b7e1a5c9f2046b2e7a1c5".into(),
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/imports.cancel \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"id":"imp_8d3b7e1a5c9f2046b2e7a1c5"},"org":"org_3f9a1c0e7b2d"}'
```

curl can’t sign a request. `$TOKEN` is your credential’s token, and `$MS_TIME` and `$MS_PROOF` sign this exact body: [Calling the API without an SDK](https://mailset.app/docs/authentication/http) shows how.

CLI:

```bash
mailset imports cancel imp_8d3b7e1a5c9f2046b2e7a1c5
```

### Response

```json
{
  "ok": true,
  "data": {
    "cancelled": true
  }
}
```

In the CLI: [mailset reference](https://mailset.app/docs/cli/imports#imports-cancel)

---

© 2026 Intenseloop, Inc. Mailset’s site, docs and guides are copyrighted. You may read them and use their code to build with Mailset. Don’t republish them or use them to build a copy of Mailset. Terms: https://mailset.app/terms#content