JavaScript SDK: swarmhit.campaigns.create(params?)
Creates a campaign (paused by default). You can set everything up front:
the sender pool (linkedinAccountIds), the outreach sequence (its
steps), the send schedule, aiInterestEnabled, the email
unsubscribe line and tracking, the lead-exclusion
rules (excludeListIds plus the exclude* flags), and the initial
status. Anything omitted falls back to a sensible default (empty
sequence, default 9-19 Mon-Fri schedule, paused). Then add leads with
POST /campaigns/{id}/leads and set status to active. Created
active, it needs a sequence with something to send in every step, or
it is a 400 with code: empty-step, and its senders are checked as on
activation (see PATCH /campaigns/{id}).
Sequence wiring: omit id/parent/branch on every step to have them
auto-wired into a linear chain in array order (each step attaches to the
previous step's natural continuation — the "yes" branch of a connection
request or condition, but the "no"/still-no-reply branch after a
message, voice note, InMail or email since their "yes"/Replied branch
ends the sequence, otherwise
its single child). To build a branching tree, give each step a stable
id and set parent/branch. Once the lead is connected — the "yes"
branch of a connection request (invite, "Accepted") or of an
if_connected condition ("Connected") — the invite, inmail,
if_connected and if_open_profile steps can't sit below it (the lead
is already connected, so a connection request / InMail can't fire and a
repeat connected / open-profile check is redundant). To send an InMail
only when a request goes unanswered, wire it onto the invite's "no"
(Still not accepted) branch, not the linear/"yes" continuation. The
inmail step's config.whenUnable (auto | pause | skip, default
auto) picks what happens when the InMail can't be sent (the sender
has no premium LinkedIn plan, or it is out of InMail credits and cannot
InMail this lead for free; only Sales Navigator and Recruiter senders
InMail open profiles free): auto pauses the
sender when out of credits and otherwise continues to the still-no-reply
branch, pause always pauses the sender, skip always continues.
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
curl -X POST "https://example.com/campaigns" \ -H "Content-Type: application/json" \ -d '{ "name": "Q3 — Founders", "linkedinAccountIds": [ "aCc123", "aCc456" ], "schedule": { "timezone": "America/New_York", "activeHours": { "from": "09:00", "to": "17:00" }, "activeDays": [ 1, 2, 3, 4, 5 ] }, "sequence": { "steps": [ { "type": "visit_profile", "nextDelayHours": 24 }, { "type": "invite", "config": { "note": "Hi {{firstName}}, came across your profile…", "fallbackNote": "Hi there, came across your profile…", "withdrawEnabled": true, "withdrawDays": 25 }, "branchDelays": { "no": 336 } }, { "type": "message", "config": { "text": "Thanks for connecting, {{firstName}}!" } } ] } }'{ "data": { "id": "string", "name": "string", "status": "draft", "stats": { "total": 0, "done": 0, "failed": 0 }, "aiInterestEnabled": true, "unsubscribe": { "enabled": true, "text": "string" }, "tracking": { "opens": "mailbox", "clicks": "mailbox" }, "linkedinAccountIds": [ "string" ], "emailAccountIds": [ "string" ], "whatsappAccountIds": [ "string" ], "senderIds": [ "string" ], "excludeListIds": [ "string" ], "listId": "string", "excludeOtherCampaigns": true, "excludeOtherSenders": true, "excludeSameSenderOtherCampaigns": true, "companyLimit": { "max": 1, "period": "day", "scope": "campaign" }, "pauseCompanyOnReply": true, "outOfOffice": { "enabled": true, "fallbackDays": 7 }, "matchEmailProvider": true, "schedule": { "startDate": "2019-08-24T14:15:22Z", "endDate": "2019-08-24T14:15:22Z", "timezone": "string", "activeHours": { "from": "string", "to": "string" }, "activeDays": [ 0 ] }, "createdAt": "2019-08-24T14:15:22Z", "updatedAt": "2019-08-24T14:15:22Z", "sequence": { "steps": [ { "id": "string", "type": "if_connected", "parent": "string", "branch": "yes", "config": {}, "nextDelayHours": 0, "branchDelays": { "yes": 0, "no": 0 } } ] } }}Stop the lead's sequence POST
**JavaScript SDK:** [`swarmhit.callTasks.stop(callTaskId, params?)`](/smart-api/sdk/methods#callTasks) Stop the lead's sequence from the task, for example when the call showed they are not interested: the lead ends with status `stopped` (and `lead.status_changed` fires). An optional outcome and note record the call on the task. A lead whose sequence can no longer be stopped is a 400 with `code: warning-call-task-stop-failed`, and the task stays `pending`. An unknown id is a 400 with `code: warning-call-task-not-found`, and a task that is no longer `pending` a 400 with `code: warning-call-task-decided`. A task whose lead already left the step on its own is closed, and returns a 400 with `code: warning-call-task-stale`. A task decided elsewhere at the same moment (in the app, or by another call) is a 400 with `code: warning-call-task-raced`: the first decision stands.
Delete a campaign DELETE
**JavaScript SDK:** [`swarmhit.campaigns.delete(campaignId)`](/smart-api/sdk/methods#campaigns) Permanently deletes the campaign and removes every lead's membership in it. This cannot be undone.