Skip to the documentation
API

Connected mailboxes

Every operation in this group: what it accepts, what it returns and the errors it can answer with.

Operations

Mailboxes that stay at Gmail, Outlook, Yahoo, iCloud or another provider and are worked from Nextmail. New mail is copied in within minutes, read, starred, archived, spam and deleted go back to the provider, and mail written as the address is sent through the provider, so it lands in its Sent folder as well. An Outlook.com or Microsoft 365 mailbox is connected in the app with a Microsoft sign-in, and then works here like any other.

GET/connected-mailboxes

List connected mailboxes

Scopesthreads:readReads

Lists the mailboxes connected to this workspace, newest first. A key or app limited to particular addresses sees only the mailboxes of those addresses.

Requires the threads:read scope.

Returns

Every connected mailbox the caller may see.

Errors

The errors every operation can return400401403404422429500Error catalog

Also available in

TypeScript
nextmail.connectedMailboxes.list()
Python
connected_mailboxes.list()
Ruby
connected_mailboxes.list
PHP
connectedMailboxes->list
Go
ConnectedMailboxes.List
Java
connectedMailboxes().list
C#
ConnectedMailboxes.ListAsync
CLI
nextmail connected-mailboxes list
MCP
listConnectedMailboxes

POST/connected-mailboxes

Connect a mailbox

Scopesdomains:writeChanges data

Connects a mailbox at another provider, so its address becomes an address of the workspace while its mail stays where it is. It signs in to the incoming and the outgoing server with the password, keeps the password sealed, adds the address, and starts copying new mail in within a minute. With importHistory it also starts an import of the mail already there, which GET /imports/{id} follows.

Gmail, Yahoo, iCloud and most providers need an app password, made in the account's security settings, not the everyday password. Leave host and smtpHost out to have the servers found from the address, as GET /connected-mailboxes/settings shows. Mail from a connected address is sent through the provider, never through Nextmail's servers, and only to people: broadcasts, automations, sign-up forms and API sends from it are refused. A key or app limited to particular addresses or domains cannot connect a mailbox. The address counts toward the plan's addresses, and every sign-in attempt counts toward the 10 an hour each person may make.

Requires the domains:write scope.

Request body

emailstringRequired

The address of the mailbox, such as you@gmail.com.

3 to 320 characters
passwordstringRequired

The app password of the mailbox, or its password where the provider has no app passwords. It is kept sealed and used only to sign in to its mail servers.

1 to 1024 characters
hoststring

The IMAP server. Leave it out to have it looked up from the address.

1 to 253 characters
portinteger

The IMAP port: 993 with TLS, or 143 with STARTTLS.

At least 1At most 65535
securitystring

How the IMAP connection is encrypted.

One of"tls""starttls"
usernamestring

The name to sign in with, when it is not the address.

1 to 320 characters
smtpHoststring

The SMTP server mail is sent through. Leave it out to have it found.

1 to 253 characters
smtpPortinteger

The SMTP port: 465 with TLS, or 587 with STARTTLS.

At least 1At most 65535
smtpSecuritystring

How the SMTP connection is encrypted.

One of"tls""starttls"
labelstring

A name for the address, shown beside it in the app.

Can be nullUp to 120 characters
importHistoryboolean

Whether to copy the mail already in the mailbox as well. Without it only mail that arrives from now on comes in.

Returns

The mailbox, with status active.

Errors

400

mailbox_login_failed: the mail server did not accept the address and password. mailbox_settings_unknown: no server was found for the address, so send host. mailbox_host_not_allowed: the host is not public, or the port is not 993 or 143. mailbox_uses_microsoft: the mailbox only opens through the Microsoft sign-in in the app. connected_mailbox_send_sign_in_failed: the outgoing server refused the password. connected_mailbox_send_server_unknown: no outgoing server answered, so send smtpHost. connected_mailbox_domain_hosted: mail for the address already comes to Nextmail, so it needs no connecting.

403

connected_mailbox_not_allowed: the caller may not connect mailboxes, or the key lacks the scope.

409

connected_mailbox_already_connected: the mailbox is already connected here. connected_mailbox_connected_elsewhere: another workspace has it connected.

422

workspace_limit_reached: the plan holds no more addresses. capability_unsupported: the key or app is limited to particular addresses or domains.

429

mailbox_checks_limited: too many sign-in attempts in the last hour.

rate_limited: the key or app made more than 600 requests in 60 seconds. Wait for the seconds in Retry-After.

502

mailbox_unreachable: the mail server did not answer.

The errors every operation can return401404500Error catalog

Also available in

TypeScript
nextmail.connectedMailboxes.connect()
Python
connected_mailboxes.connect()
Ruby
connected_mailboxes.connect
PHP
connectedMailboxes->connect
Go
ConnectedMailboxes.Connect
Java
connectedMailboxes().connect
C#
ConnectedMailboxes.ConnectAsync
CLI
nextmail connected-mailboxes connect

GET/connected-mailboxes/settings

Find the mail servers for a mailbox

Scopesdomains:writeReads

Looks up where the mailbox behind an address lives and what it signs in with, so the right password can be asked for before connecting it. Nothing is stored and no sign-in is attempted.

Requires the domains:write scope.

Query parameters

emailstringRequired

The address of the mailbox.

Formatemail

Returns

What was found for the address.

Errors

400

mailbox_address_invalid: that is not an email address.

429

mailbox_checks_limited: too many lookups in the last hour.

rate_limited: the key or app made more than 600 requests in 60 seconds. Wait for the seconds in Retry-After.

The errors every operation can return401403404422500Error catalog

Also available in

TypeScript
nextmail.connectedMailboxes.discover()
Python
connected_mailboxes.discover()
Ruby
connected_mailboxes.discover
PHP
connectedMailboxes->discover
Go
ConnectedMailboxes.Discover
Java
connectedMailboxes().discover
C#
ConnectedMailboxes.DiscoverAsync
CLI
nextmail connected-mailboxes discover
MCP
getConnectedMailboxSettings

GET/connected-mailboxes/{id}

Get a connected mailbox

Scopesthreads:readReads

Returns one connected mailbox: whether it is syncing, when it last did, and what went wrong if it did not.

Requires the threads:read scope.

Path parameters

idstringRequired

The connected mailbox, such as cmb_5c1e9a7b3d2f48e6a0b4c7d1, as GET /connected-mailboxes lists it.

Returns

The mailbox.

Errors

404

connected_mailbox_not_found: no such connected mailbox in this workspace.

The errors every operation can return400401403422429500Error catalog

Also available in

TypeScript
nextmail.connectedMailboxes.get()
Python
connected_mailboxes.get()
Ruby
connected_mailboxes.get
PHP
connectedMailboxes->get
Go
ConnectedMailboxes.Get
Java
connectedMailboxes().get
C#
ConnectedMailboxes.GetAsync
CLI
nextmail connected-mailboxes get
MCP
getConnectedMailbox

PATCH/connected-mailboxes/{id}

Update a connected mailbox

Scopesdomains:writeChanges data

Pauses or resumes it, renames its address, or gives it a new app password after the provider stopped accepting the old one. A new password is checked against both servers before it is kept, and a mailbox that needed signing in starts syncing again. Pausing stops both syncing and sending through it; mail already copied in stays.

Requires the domains:write scope.

Path parameters

idstringRequired

The connected mailbox, such as cmb_5c1e9a7b3d2f48e6a0b4c7d1, as GET /connected-mailboxes lists it.

Request body

pausedboolean

true stops syncing and sending through the mailbox, false starts it again.

passwordstring

A new app password, after the old one stopped working. It is checked against both mail servers before it is kept.

1 to 1024 characters
labelstring

A name for the address, or null to clear it.

Can be nullUp to 120 characters

Returns

The mailbox as it is now.

Errors

400

mailbox_login_failed: the mail server did not accept the address and password. mailbox_settings_unknown: no server was found for the address, so send host. mailbox_host_not_allowed: the host is not public, or the port is not 993 or 143. mailbox_uses_microsoft: the mailbox only opens through the Microsoft sign-in in the app. connected_mailbox_send_sign_in_failed: the outgoing server refused the password. connected_mailbox_send_server_unknown: no outgoing server answered, so send smtpHost. connected_mailbox_no_password: the mailbox signs in with Microsoft, so it has no password to change.

403

connected_mailbox_not_allowed: the caller may not change connected mailboxes.

404

connected_mailbox_not_found: no such connected mailbox in this workspace.

429

mailbox_checks_limited: too many sign-in attempts in the last hour.

rate_limited: the key or app made more than 600 requests in 60 seconds. Wait for the seconds in Retry-After.

502

mailbox_unreachable: the mail server did not answer.

The errors every operation can return401422500Error catalog

Also available in

TypeScript
nextmail.connectedMailboxes.update()
Python
connected_mailboxes.update()
Ruby
connected_mailboxes.update
PHP
connectedMailboxes->update
Go
ConnectedMailboxes.Update
Java
connectedMailboxes().update
C#
ConnectedMailboxes.UpdateAsync
CLI
nextmail connected-mailboxes update
MCP
updateConnectedMailbox

DELETE/connected-mailboxes/{id}

Disconnect a mailbox

Scopesdomains:writeDeletes

Stops syncing and sending through the mailbox, forgets its password and removes its address from the workspace. The mail already copied in stays in Nextmail, and nothing is changed at the provider. An import of its history that is still running is cancelled.

Requires the domains:write scope.

Path parameters

idstringRequired

The connected mailbox, such as cmb_5c1e9a7b3d2f48e6a0b4c7d1, as GET /connected-mailboxes lists it.

Returns

The mailbox that was disconnected.

Errors

403

connected_mailbox_not_allowed: the caller may not change connected mailboxes.

404

connected_mailbox_not_found: no such connected mailbox in this workspace.

The errors every operation can return400401422429500Error catalog

Also available in

TypeScript
nextmail.connectedMailboxes.disconnect()
Python
connected_mailboxes.disconnect()
Ruby
connected_mailboxes.disconnect
PHP
connectedMailboxes->disconnect
Go
ConnectedMailboxes.Disconnect
Java
connectedMailboxes().disconnect
C#
ConnectedMailboxes.DisconnectAsync
CLI
nextmail connected-mailboxes disconnect
MCP
disconnectConnectedMailbox

POST/connected-mailboxes/{id}/sync

Sync a connected mailbox now

Scopesthreads:writeChanges data

Asks for a sync straight away instead of at the next interval. A mailbox is synced every 30 seconds while mail comes in, and less often after it has been quiet for a while. It answers at once; the sync follows within seconds. A paused mailbox, or one that needs signing in, is not synced.

Requires the threads:write scope.

Path parameters

idstringRequired

The connected mailbox, such as cmb_5c1e9a7b3d2f48e6a0b4c7d1, as GET /connected-mailboxes lists it.

Returns

The mailbox.

Errors

404

connected_mailbox_not_found: no such connected mailbox in this workspace.

The errors every operation can return400401403422429500Error catalog

Also available in

TypeScript
nextmail.connectedMailboxes.sync()
Python
connected_mailboxes.sync()
Ruby
connected_mailboxes.sync
PHP
connectedMailboxes->sync
Go
ConnectedMailboxes.Sync
Java
connectedMailboxes().sync
C#
ConnectedMailboxes.SyncAsync
CLI
nextmail connected-mailboxes sync
MCP
syncConnectedMailbox

Objects

ConnectedMailboxobject

objectstringRequired
One of"connected_mailbox"
idstringRequired

The id, which starts with cmb_.

addressIdstringRequired

The address the mailbox appears as in the workspace, for the address and mail calls.

emailstringRequired

The address of the mailbox, lower-cased.

Formatemail
labelstringRequired

The name given to the address, if any.

Can be null
providerstringRequired

The provider the mailbox lives at, or other.

One of"gmail""outlook""yahoo""aol""icloud""fastmail""zoho""other"
methodstringRequired

How Nextmail reaches the mailbox: imap with an app password, or microsoft through a Microsoft sign-in made in the app.

One of"imap""microsoft"
statusstringRequired

active syncs and sends. paused does neither until it is resumed. needs-sign-in means the provider stopped accepting the password: send a new one with PATCH, or sign in to Microsoft again in the app for a microsoft mailbox. failing means the last five syncs failed, and it keeps trying less often.

One of"active""paused""needs-sign-in""failing"
pauseReasonstringRequired

Why it is not active: by-person, sign-in or unreachable. Null while active.

Can be nullOne of"by-person""sign-in""unreachable"
lastErrorstringRequired

What the mail server said the last time something went wrong, or null.

Can be null
lastSyncedAtstringRequired

When it last finished a sync, or null before the first one.

Can be nullFormatdate-time
createdAtstringRequired

When it was connected.

Formatdate-time
connectedBystringRequired

The user id of the person who connected it.

usernamestringRequired

The name it signs in with, usually the address.

Can be null
imapobjectRequired

The server mail is read from, or null for a microsoft mailbox.

Can be null
hoststringRequired

The host name, such as imap.gmail.com or smtp.gmail.com.

portintegerRequired

The port.

At least 1At most 65535
securitystringRequired

tls encrypts from the first byte, starttls upgrades a plain connection.

One of"tls""starttls"
smtpobjectRequired

The server mail is sent through, or null for a microsoft mailbox.

Can be null
hoststringRequired

The host name, such as imap.gmail.com or smtp.gmail.com.

portintegerRequired

The port.

At least 1At most 65535
securitystringRequired

tls encrypts from the first byte, starttls upgrades a plain connection.

One of"tls""starttls"
historyImportIdstringRequired

The import that copies the mail already in the mailbox, when importHistory was asked for, as the imports calls name it.

Can be null

ConnectedMailboxSettingsobject

objectstringRequired
One of"connected_mailbox_settings"
emailstringRequired

The address looked up, lower-cased.

Formatemail
providerstringRequired

The provider the address belongs to, or other.

One of"gmail""outlook""yahoo""aol""icloud""fastmail""zoho""other"
signInstringRequired

app-password and password are what POST /connected-mailboxes takes. microsoft means the mailbox only opens through the Microsoft sign-in in the app.

One of"app-password""password""microsoft"
imapobjectRequired

Where mail is read from, or null when nothing was found and host has to be given.

Can be null
hoststringRequired

The host name, such as imap.gmail.com or smtp.gmail.com.

portintegerRequired

The port.

At least 1At most 65535
securitystringRequired

tls encrypts from the first byte, starttls upgrades a plain connection.

One of"tls""starttls"
smtpobjectRequired

Where mail is sent through, when the provider is known. Null means it is found when the mailbox is connected, or smtpHost can be given.

Can be null
hoststringRequired

The host name, such as imap.gmail.com or smtp.gmail.com.

portintegerRequired

The port.

At least 1At most 65535
securitystringRequired

tls encrypts from the first byte, starttls upgrades a plain connection.

One of"tls""starttls"

DeletedConnectedMailboxobject

objectstringRequired
One of"connected_mailbox"
idstringRequired

The id of the mailbox that was disconnected.

addressIdstringRequired

The address it appeared as.

emailstringRequired

The address of the mailbox.

Formatemail
deletedbooleanRequired
One oftrue