Imports
Copy a mailbox’s email over from a Google account.
An SDK signs every request with your key: Authentication. To sign one yourself, see Calling the API without an SDK.
On this page
imports.start
Copy a mailbox’s mail from a Google account: opens Google to connect.
POST/v1/imports.start
Parameters
The mailbox the mail is copied into.
Which of the mailbox’s addresses. Leave out for all of them.
At most 100 items.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is an object with:
The import’s id.
Google’s page to open, to connect the account.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.imports.start({
mailbox: "moc.elpmaxe@ana",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.imports.start(
{"mailbox": "moc.elpmaxe@ana"}
)
print(answer)
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: "moc.elpmaxe@ana",
}
answer, err := client.Imports.Start(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.imports.start(mailbox: 'moc.elpmaxe@ana')
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->imports->start([
'mailbox' => 'moc.elpmaxe@ana',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
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("moc.elpmaxe@ana")
.build();
ImportsStartResult answer =
mailset.imports().start(params);
System.out.println(answer);
use mailset::types::ImportsStartParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.imports()
.start(ImportsStartParams {
mailbox: "moc.elpmaxe@ana".into(),
..Default::default()
})
.await?;
println!("{answer:?}");
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":"moc.elpmaxe@ana"},"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 shows how.
mailset imports start moc.elpmaxe@ana
{
"ok": true,
"data": {
"id": "out_3f9a1c0e7b2d",
"url": "https://hooks.example.com/mailset"
}
}
imports.list
List Gmail imports.
POST/v1/imports.list
Parameters
It takes no input: send an empty object.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is a list of objects, each with:
The import’s id.
The mailbox the mail is copied into.
The addresses whose mail is copied: the mailbox’s own and its aliases.
The Google account it copies from, once connected.
How far along it is.
One of
connectinglistingcopyingdonefailedcancelledMessages found so far.
Messages copied so far.
Messages left out so far.
Why it failed, when it did.
It is waiting because the org’s plan ended. It carries on once the plan is live again.
When it started, in milliseconds since 1970.
When it finished, in milliseconds since 1970, or null while it runs.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.imports.list();
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.imports.list()
print(answer)
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)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.imports.list
p answer
<?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;
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);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset.imports().list().await?;
println!("{answer:?}");
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 shows how.
mailset imports list
{
"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
}
]
}
imports.cancel
Stop an import and end its access to Google.
POST/v1/imports.cancel
Parameters
The import’s id, from
imports list.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is an object with:
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);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.imports.cancel(
{"id": "imp_8d3b7e1a5c9f2046b2e7a1c5"}
)
print(answer)
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)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.imports.cancel(
id: 'imp_8d3b7e1a5c9f2046b2e7a1c5'
)
p answer
<?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;
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);
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 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 shows how.
mailset imports cancel imp_8d3b7e1a5c9f2046b2e7a1c5
{
"ok": true,
"data": {
"cancelled": true
}
}