API referenceEmail accounts
POST
/email-accounts/connect/batch

JavaScript SDK: swarmhit.emailAccounts.connectBatch(params)

Connect up to 20 mailboxes in one call, each as POST /email-accounts/connect connects one. They are answered in the order sent (results[].index), and a refused one never stops the others: status is connected, failed (its error.code and message, as the single connect's refusals; duplicate for an address already earlier in the same call), or not-attempted (the call ran out of time before it: send those again). Mailboxes connect a few at a time per workspace, the app's CSV import included. startWarmup applies to every mailbox of the call.

Authorization

bearerAuth
AuthorizationBearer <token>

An API key created on the Access tokens page.

In: header

Header Parameters

Idempotency-Key?string

Unique key per action (e.g. a UUID). Reusing it replays the first response instead of sending again, so a retry can't double-send. Read only by the endpoints that list it. A key is scoped to the endpoint and the account (or chat) it acts on, and kept for 24 hours. Only a successful response is stored and replayed: a 4xx frees the key, while a 5xx keeps it (the action may have gone out; retry with a new key). So does a 400 passing on a LinkedIn, WhatsApp or mail provider failure (code provider-unreachable, provider-408 for the provider's own timeout, or provider- and a 5xx status such as provider-502), unless the request provably never reached the provider (its connection never opened): the action may have gone out. A retry with the same key then gets 409 idempotency_failed. The request body is not compared, so a reused key replays the first response even if the body differs.

Lengthlength <= 255

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/email-accounts/connect/batch" \  -H "Content-Type: application/json" \  -d '{    "mailboxes": [      {        "provider": "google",        "email": "user@example.com"      }    ]  }'
{  "data": {    "results": [      {        "index": 0,        "email": "string",        "status": "connected",        "account": {          "id": "string",          "label": "string",          "senderId": "string",          "email": "string",          "fromName": "string",          "picture": "string",          "provider": "google",          "authType": "password",          "connectedVia": "app",          "hostedLinkId": "string",          "status": "pending",          "error": "string",          "limits": {},          "usage": {},          "paused": true,          "pausedReason": "user",          "pausedAt": "2019-08-24T14:15:22Z",          "trackOpens": true,          "trackClicks": true,          "dnsHealth": {            "domain": "string",            "managed": true,            "spf": {              "status": "ok",              "reason": "string"            },            "dkim": {              "status": "ok",              "reason": "string",              "selector": "string"            },            "dmarc": {              "status": "ok",              "reason": "string",              "policy": "none"            },            "checkedAt": "2019-08-24T14:15:22Z"          },          "deliverabilityTest": {            "status": "running",            "startedAt": "2019-08-24T14:15:22Z",            "finishedAt": "2019-08-24T14:15:22Z",            "landing": "inbox",            "spf": "string",            "dkim": {              "result": "string",              "selector": "string"            },            "dmarc": "string",            "blocklists": {              "ip": "clean",              "domain": "clean"            },            "failure": "send"          },          "counters": {},          "createdAt": "2019-08-24T14:15:22Z",          "updatedAt": "2019-08-24T14:15:22Z",          "managed": {            "provider": "string",            "domain": "string",            "status": "string",            "renewsAt": "2019-08-24T14:15:22Z",            "cancelAt": "2019-08-24T14:15:22Z",            "isAdmin": true          },          "warmup": {            "provider": "string",            "status": "pending",            "statusLabel": "string",            "strategy": {              "preset": "conservative",              "startingVolume": 1,              "dailyIncrease": 1,              "targetVolume": 1,              "replyInbox": [                0,                0              ],              "replyPromotions": [                0,                0              ],              "replySpam": 0            },            "strategyApplied": true,            "day": 0,            "currentVolume": 0,            "targetVolume": 0,            "health": "excellent",            "healthLabel": "string",            "healthScore": 0,            "inboxRate": 0,            "startedAt": "2019-08-24T14:15:22Z",            "holdUntil": "2019-08-24T14:15:22Z",            "holdReason": "warming",            "holdOverride": true,            "syncedAt": "2019-08-24T14:15:22Z",            "error": "string"          },          "restoredFrom": "string"        },        "restored": {          "campaigns": 0,          "leads": 0        },        "warmup": {          "started": true,          "status": "string",          "code": "string",          "message": "string"        },        "error": {          "code": "string",          "message": "string",          "leg": "imap",          "response": "string",          "accountId": "string"        }      }    ],    "connected": 0,    "failed": 0,    "notAttempted": 0  }}

Connect a mailbox POST

**JavaScript SDK:** [`swarmhit.emailAccounts.connect(params)`](/smart-api/sdk/methods#emailAccounts) Connect an existing mailbox with its logins: a Google app password (`provider: google`), or IMAP and SMTP servers (`provider: imap`). It is connected as the app's Connect form and CSV import connect one: both logins are tried first, a seat is taken, and an address the workspace removed before comes back with its campaigns. The password goes to our email gateway as the app sends it, and is never stored by Swarmhit, logged, or answered back. A Microsoft mailbox connects through a hosted link instead (POST /email-accounts/hosted-link). With `startWarmup`, warmup starts on the mailbox once it connects, with the same password: `warmup` says whether it started, or why not (a personal address such as Gmail never warms). The key's creator must still be a member of the workspace the key was made in (403 `forbidden` otherwise). Refusals: 400 `invalid-row` (a missing or invalid field, servers, port or password; `message` says which), `sign-in-required` (a Microsoft mailbox) or `no-plan` (no seat left); 409 `already-connected` (the workspace has this address: `details.accountId`) or `in-progress`; 422 `invalid-credentials` (a server refused the login) or `connection-failed` (a server could not be reached), each with `details.leg` (`imap` or `smtp`) and, when it said something, `details.response` (the mail server's own words); 429 `rate-limited`; 503 `service-unavailable`.

Create a hosted connect link for a mailbox POST

**JavaScript SDK:** [`swarmhit.emailAccounts.hostedLinks.create(params)`](/smart-api/sdk/methods#emailAccounts.hostedLinks) The mailbox version of POST /accounts/hosted-link, and how the API connects a mailbox without handling its password: mint a one-time URL, send the person to it, and they connect on a page Swarmhit serves in your organization's branding, with one of the `providers` the link offers (the person picks when there are several). `google` and `microsoft` sign in on the provider's own page; `google_app_password` takes a Google app password, and `imap` the address, password and IMAP/SMTP servers of any other mailbox. `provider` is the one-value form. `buy_mailboxes` lets the person buy new domains and mailboxes on the page, up to `purchase.maxMailboxes` in all, charged to the card your organization pays with; no price is shown on the page. Offering it needs `managedMailboxes` on the workspace and a card on file (409 `no-payment-method`), and the API key's creator needs billing rights (403 `not-allowed`). The link then ends as `ordered`: the redirect carries `status=ordered&order_id=`, the mailboxes are set up over the next hours, and `mailbox_order.completed` and each mailbox's account.connected carry `hostedLinkId` and `externalId`. The mailbox lands in the effective workspace (X-Swarmhit-Workspace), which needs a paid plan, checked when the link is created; a mailbox takes no seat. The workspace needs the email channel (403 otherwise), and the server needs each provider set up (409 `provider-unavailable` otherwise). With `accountId` the link REPAIRS that mailbox (status `error`): it keeps its id, campaigns and seat, and offers only the mailbox's own provider, so `providers` and `provider` may be left out. A signed-in mailbox signs in again as the same address (a different one is refused on the page); a password mailbox keeps its address, servers and usernames and takes new passwords. A mailbox bought through Swarmhit reconnects by itself and is refused (409 `managed-mailbox`). You learn the outcome exactly as for a sender: the redirect back carries `?hosted_link_id=&status=connected|ordered|failed|expired|cancelled&account_id=&order_id=&external_id=` (`account_id` is the mailbox id); account.connected (with `data.channel: email`) and account.connection_failed carry `hostedLinkId` and `externalId`; and GET /email-accounts/hosted-link/{id} returns the current state. A failed attempt leaves the link open so the person can try again; only cancelling or expiry ends it without a mailbox. `url` is returned once, here.