JavaScript SDK: swarmhit.embed.sessions.create(params)
Starts a session for one of your users, so your page can show them the
Swarmhit inbox, tasks and campaigns. Call it from your backend, never
from the browser: it takes your API key. Pass the returned
clientSecret to your page, which hands it to the embedded components.
On the page: load https://app.swarmhit.com/embed.js, place an element
such as <swarmhit-inbox theme="auto">, and call
Swarmhit.init({ fetchClientSecret }) with a function that asks your
backend for a secret. The integration guide has the full walkthrough.
The elements are <swarmhit-inbox>, <swarmhit-tasks> and
<swarmhit-campaigns>. Each one calls fetchClientSecret when it
loads and again when its session ends, so the function must return a
fresh secret every time.
The secret works once and only for 5 minutes. The session it starts
lasts 12 hours. The user reaches only the LinkedIn accounts in
accountIds: their conversations, and the campaigns whose every sender
is one of them. They reach none of your settings, accounts or billing.
permissions says what they may do there, for example
["inbox", "tasks", "campaigns.analytics", "campaigns.leads"]. A
screen's name (inbox, tasks, campaigns) grants all of that
screen; an edit permission includes its read. Screens and tabs the user
lacks are not shown, and Swarmhit refuses anything outside them, so the
list is the boundary, not a display setting. Campaigns they create send
from their accounts.
Your latest session for a user sets what all of their open components reach, so a call with fewer accounts or permissions narrows the screens they already have open.
Authorization
bearerAuth An API key created on the Access tokens page.
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
curl -X POST "https://example.com/embed/sessions" \ -H "Content-Type: application/json" \ -d '{ "user": { "id": "recruiter_481", "name": "Jane Doe" }, "accountIds": [ "a1B2c3D4e5F6g7H8i", "j9K0l1M2n3O4p5Q6r" ], "permissions": [ "inbox", "tasks", "campaigns.analytics", "campaigns.leads.manage", "campaigns.sequence.edit", "campaigns.status" ] }'{ "data": { "clientSecret": "string", "expiresAt": "2019-08-24T14:15:22Z", "user": { "id": "string", "name": "string" }, "accountIds": [ "string" ], "permissions": [ "string" ] }}Set a mailbox's sender PATCH
**JavaScript SDK:** [`swarmhit.emailAccounts.update(emailAccountId, params)`](/smart-api/sdk/methods#emailAccounts) Sets the mailbox's `senderId` (`null` unlinks it). `senderId` is the only field. Needs the email channel enabled for the workspace (`403` otherwise).
End a user's embedded sessions DELETE
**JavaScript SDK:** [`swarmhit.embed.users.revokeSessions(userId)`](/smart-api/sdk/methods#embed.users) Ends every session of one of your users at once: secrets not used yet stop working and their open components are signed out. Call it when a user leaves your platform or loses access. `revoked` is false when that user never had a session.