Email accounts
POST
/email-accounts/hosted-link

The mailbox version of POST /accounts/hosted-link, and how the API connects a Google mailbox (Gmail, Google Workspace) or a Microsoft one (Outlook.com, Hotmail, Microsoft 365): signing in with the provider needs a browser, so you mint a one-time URL for provider, send the person to it, and they click "Sign in with Google" or "Sign in with Microsoft" on a page Swarmhit serves in your organization's branding. The provider takes their password on its own page; neither you nor we ever see it.

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 that provider's sign-in set up (409 provider-unavailable otherwise).

With accountId the link REPAIRS that mailbox (one whose access expired or was revoked, status error): the person signs in again as the same address and it keeps its id, campaigns and seat. A different address is refused on the page. Only a mailbox that signed in can be repaired this way (authType: oauth); provider may then be left out. 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|failed|expired|cancelled&account_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 sign-in 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",    "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"  }}