Skip to main content

Campaigns

A campaign is a bulk send to a resolved audience. Every write endpoint here lists its prerequisites. See the Campaigns guide.

Base URL https://api.leadx.in/api/key/protected. Every request needs an apikey header — see Authentication.

17 endpoints.

GET /campaign

Get all campaigns.

Auth apikey

:::note Used by the web app pages/Campaign.jsx, pages/CreateCampaign.jsx, pages/ViewCampaign.jsx :::

Query parameters — the standard list contract: p, n, sortBy, sortOrder, searchBy, searchValue, filters, advancedFilters, ids, nids. See Pagination and Filtering.

Responsedata is an array of Campaign objects, alongside the pagination fields described in Response format. segments, updatedBy, createdBy are populated, so they arrive as nested objects rather than ids.

POST /campaign

Create campaign.

Auth apikey · Success 201

:::note Used by the web app pages/Campaign.jsx, pages/CreateCampaign.jsx, pages/ViewCampaign.jsx :::

Prerequisites

  1. An audience. At least one of segmentsBool, tagsBool, categoriesBool, contactsBool or customSegmentsBool must be true, with matching data — otherwise CampaignSegmentsRequired_400. Create whichever you will target: POST /segment · POST /tag · POST /contact-category · POST /contact
  2. Confirm the audience resolves to somebody. An empty audience refuses creation with CampaignAudienceEmpty_400. POST /campaign/audience-preview
  3. A template for the channel named in type. WhatsApp templates must be approved by Meta before a campaign can use them. POST /template/email · POST /template/whatsapp · POST /template/whatsapp/status-reconcile
  4. A sending app, passed as smtp: { id }. Required at start time for type: "email"CampaignSMTPRequired_400. POST /apps/smtp · POST /apps/ses · POST /apps/sendgrid · GET /apps/smtp

Request body

FieldDefaultNotes
nameMust be unique for the company — otherwise CampaignNameAlreadyExists_400.
typeThe channel: email, whatsapp, and the other configured channels.
description""
templateTemplate id for that channel.
segments[]Segment ids. Only read when segmentsBool is true.
smtp{ id } of the sending configuration. Required at start time for email.
intervalMsDelay between individual sends, in milliseconds — for provider rate limits.
daysOfWeekDays the campaign may send on. 06, Sunday = 0.
timeWindow{ start, end } as HH:MM, to keep sends inside business hours.
scheduleTypeHow the campaign is scheduled.
startAtISO timestamp for the first send.
endAtISO timestamp after which nothing is sent.
triggerWorkflowtrueWhether sends emit workflow events. Set false so a large campaign does not trigger thousands of workflow runs.
startCampaignfalseStart immediately. false creates it idle.
customAudienceInline audience: tags, categories, contacts, or an advanced filter.
customSegmentsBoolfalseTarget an inline advanced-filter audience.
segmentsBoolfalseTarget saved segments.
tagsBoolfalseTarget contacts carrying customAudience.tags.
categoriesBoolfalseTarget contacts in customAudience.categories.
contactsBoolfalseTarget the explicit list in customAudience.contacts.

Required: name, type.

Errors CampaignAudienceEmpty_400 · CampaignNameAlreadyExists_400 · CampaignSMTPNotBelongToCompany_400 · CampaignSMTPNotFound_400 · CampaignSMTPRequired_400 · CampaignSegmentNotFound_400 · CampaignSegmentsRequired_400

DELETE /campaign

Delete campaigns.

Auth apikey · Success 200

:::note Used by the web app pages/Campaign.jsx, pages/CreateCampaign.jsx, pages/ViewCampaign.jsx :::

Request body — the standard bulk selection: ids, nids, selectAll. Query-string filters apply when selectAll is set.

Responsedata is null; the outcome is the status code and message.

GET /campaign/:id

Get campaign.

Auth apikey

:::note Used by the web app components/CampaignSetup.jsx, components/ContentMessaging.jsx, components/ScheduleDelivery.jsx and 4 more :::

Path parameters

Name
idRequired

Responsedata is one Campaign object.

Errors CampaignNotFound_404 · UnsupportedCampaignType_400

PUT /campaign/:id

Update campaign.

Auth apikey

:::note Used by the web app components/CampaignSetup.jsx, components/ContentMessaging.jsx, components/ScheduleDelivery.jsx and 4 more :::

Prerequisites

  1. An existing campaign. A campaign that has already started may refuse edits with CampaignCannotBeUpdated_400. GET /campaign · POST /campaign

Path parameters

Name
idRequired

Request body

FieldDefault
startCampaign

Responsedata is one Campaign object. (Resource deduced from the collections this handler reads, not read off an explicit return.)

Errors CampaignCannotBeUpdated_400 · CampaignNotFound_404 · CampaignSegmentsRequired_400

POST /campaign/:id/assignTag

Assign tag to failed contacts.

Auth apikey · Success 200

:::note Used by the web app pages/ManualCampaignDetail.jsx, pages/ViewCampaign.jsx :::

Prerequisites

  1. A campaign with failed recipients, and a tag to assign them. GET /campaign/:id/recipients · POST /tag

Path parameters

Name
idRequired

Request body

FieldDefault
name

Required: name.

Responsedata is one Campaign object. (Resource deduced from the collections this handler reads, not read off an explicit return.)

Errors CampaignNotFound_404 · NoCampaignSelected_400 · TagNameAlreadyExists_400

PUT /campaign/:id/continue

Failed to active.

Auth apikey

:::note Used by the web app pages/Campaign.jsx :::

Prerequisites

  1. A campaign in a failed state. Repeated failures are refused with CampaignFailedManyTime_400. GET /campaign

Path parameters

Name
idRequired

Responsedata is one ResponseMessage object. (Resource deduced from the collections this handler reads, not read off an explicit return.)

Errors CampaignCannotBeUpdated_400 · CampaignFailedManyTime_400 · CampaignNotFound_404

GET /campaign/:id/logs

Get all campaign logs.

Auth apikey

:::note Used by the web app pages/ViewCampaign.jsx :::

Prerequisites

  1. A campaign that has run. GET /campaign · PUT /campaign/:id/play-pause

Path parameters

Name
idRequired

Query parameters — the standard list contract: p, n, sortBy, sortOrder, searchBy, searchValue, filters, advancedFilters, ids, nids. See Pagination and Filtering.

Responsedata is an array of UnifiedMessage objects, alongside the pagination fields described in Response format. contact, template, app, updatedBy, createdBy are populated, so they arrive as nested objects rather than ids.

Errors CampaignNotFound_404

PUT /campaign/:id/play-pause

Toggle campaign play pause.

Auth apikey · Success 200

:::note Used by the web app pages/Campaign.jsx :::

Prerequisites

  1. An existing campaign. For type: "email" a sending app must be attached before it can start. POST /campaign · GET /apps/smtp

Path parameters

Name
idRequired

Responsedata is one Campaign object. (Resource deduced from the collections this handler reads, not read off an explicit return.)

Errors CampaignCannotBeUpdated_400 · CampaignNotFound_404

GET /campaign/:id/recipients

Per-recipient send report from the v2 engine.

Auth apikey

Prerequisites

  1. A campaign that has started. Recipients are materialised at start time by the v2 engine, so a campaign created but never started has none. PUT /campaign/:id/play-pause · POST /campaign

Path parameters

Name
idRequired

Query parameters

FieldDefault
status
page1
limit50

Responsedata is one Campaign object. (Resource deduced from the collections this handler reads, not read off an explicit return.)

Errors CampaignNotFound_404

POST /campaign/:id/retry-failed

Retry failed campaign.

Auth apikey · Success 201

:::note Used by the web app pages/Campaign.jsx :::

Prerequisites

  1. A campaign with failed recipients. Check the report first. GET /campaign/:id/recipients

Path parameters

Name
idRequired

Responsedata is one SendJob object. (Resource deduced from the collections this handler reads, not read off an explicit return.)

Errors CampaignNotFound_404 · NoCampaignSelected_400

POST /campaign/:id/sync-failed

Failed contacts sync.

Auth apikey · Success 200

:::note Used by the web app pages/ViewCampaign.jsx :::

Prerequisites

  1. A campaign with failed recipients. GET /campaign/:id/recipients

Path parameters

Name
idRequired

Responsedata is one ResponseMessage object. (Resource deduced from the collections this handler reads, not read off an explicit return.)

Errors CampaignNotFound_404 · NoMessagesSent_400

POST /campaign/audience-preview

Resolve an audience selection to a contact count, without creating anything.

Auth apikey

Prerequisites

  1. Something to select. Send the same audience flags and data you intend to give POST /campaign. POST /segment · POST /tag · POST /contact-category · POST /contact

Request body

FieldDefault
segments[]
customAudience{}

GET /campaign/manual

Get all manual campaigns.

Auth apikey

Query parameters — the standard list contract: p, n, sortBy, sortOrder, searchBy, searchValue, filters, advancedFilters, ids, nids. See Pagination and Filtering.

Responsedata is an array of TempManualCampaign objects, alongside the pagination fields described in Response format. updatedBy, createdBy are populated, so they arrive as nested objects rather than ids.

POST /campaign/manual

Manual campaign temp.

Auth apikey

Prerequisites

  1. A template. POST /template/email · POST /template/whatsapp
  2. A sending app. GET /apps/smtp
  3. Contacts to send to. POST /contact · GET /contact

Request body

FieldDefault
templateId
columnMapping
templateName
templateSubject
campaignType
campaignName
file
delaySeconds0

Responsedata is one ResponseMessage object. (Resource deduced from the collections this handler reads, not read off an explicit return.)

Errors InvalidCampaignType_400 · InvalidMapping_400 · InvalidPayload_400 · NoFile_400 · TemplateNotFound_404

GET /campaign/manual/:id

Get manual campaigns.

Auth apikey

:::note Used by the web app pages/ManualCampaign.jsx :::

Path parameters

Name
idRequired

Responsedata is one TempManualCampaign object.

Errors ManualCampaignNotFound_404

POST /campaign/test/:type

Send a test message without touching the audience.

Auth apikey · Success 200

Prerequisites

  1. A template to render. POST /template/email · POST /template/whatsapp
  2. A sending app to send through. GET /apps/smtp

Path parameters

Name
typeRequired

Request body

FieldDefault
smtp
template
testEmail
testContactNumber{}

Responsedata is one EmailTemplate object. (Resource deduced from the collections this handler reads, not read off an explicit return.)

Errors EmailSendingFailed_500 · EmailTemplateNotFound_404 · InvalidCampaignType_400 · MetaTemplateNotFound_404