Email accounts
POST
/email-accounts/hosted-link

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.

Authorization

bearerAuth
AuthorizationBearer <token>

An API key created under Settings → API & Webhooks.

In: header

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/hosted-link" \  -H "Content-Type: application/json" \  -d '{}'
{  "data": {    "id": "string",    "status": "pending",    "channel": "linkedin",    "provider": "google",    "providers": [      "google"    ],    "orderId": "string",    "purchase": {      "maxMailboxes": 0,      "contactProvided": true    },    "url": "string",    "workspaceId": "string",    "accountId": "string",    "reconnectAccountId": "string",    "externalId": "string",    "redirectUrl": "string",    "hasProxy": true,    "country": "string",    "error": {      "code": "string",      "message": "string"    },    "expiresAt": "2019-08-24T14:15:22Z",    "openedAt": "2019-08-24T14:15:22Z",    "completedAt": "2019-08-24T14:15:22Z",    "createdAt": "2019-08-24T14:15:22Z"  }}