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.

Response — data 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.

cURL
curl -X GET 'https://api.leadx.in/api/key/protected/campaign?p=1&n=25' \
-H 'apikey: $LEADX_API_KEY'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign?p=1&n=25', {
method: 'GET',
headers: {
apikey: process.env.LEADX_API_KEY,
},
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.get(
'/campaign?p=1&n=25'
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign?p=1&n=25',
{
method: 'GET',
headers: {
apikey: process.env.LEADX_API_KEY,
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);

req.end();
});

const { data } = await send(null);
console.log(data);
Python
import os
import requests

res = requests.get(
"https://api.leadx.in/api/key/protected/campaign?p=1&n=25",
headers={"apikey": os.environ["LEADX_API_KEY"]},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign?p=1&n=25');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
],
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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

FieldTypeRequiredDefaultNotes
nameyes—Must be unique for the company — otherwise CampaignNameAlreadyExists_400.
typeyes—The channel: email, whatsapp, and the other configured channels.
description""
template—Template id for that channel.
segmentsarray[]Segment ids. Only read when segmentsBool is true.
smtp—{ id } of the sending configuration. Required at start time for email.
intervalMs—Delay between individual sends, in milliseconds — for provider rate limits.
daysOfWeek—Days the campaign may send on. 0–6, Sunday = 0.
timeWindow—{ start, end } as HH:MM, to keep sends inside business hours.
scheduleType—How the campaign is scheduled.
startAt—ISO timestamp for the first send.
endAt—ISO timestamp after which nothing is sent.
triggerWorkflowbooleantrueWhether sends emit workflow events. Set false so a large campaign does not trigger thousands of workflow runs.
startCampaignbooleanfalseStart immediately. false creates it idle.
customAudience—Inline audience: tags, categories, contacts, or an advanced filter.
customSegmentsBoolbooleanfalseTarget an inline advanced-filter audience.
segmentsBoolbooleanfalseTarget saved segments.
tagsBoolbooleanfalseTarget contacts carrying customAudience.tags.
categoriesBoolbooleanfalseTarget contacts in customAudience.categories.
contactsBoolbooleanfalseTarget the explicit list in customAudience.contacts.
cURL
curl -X POST 'https://api.leadx.in/api/key/protected/campaign' \
-H 'apikey: $LEADX_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"name": "",
"type": "",
"description": "",
"template": "",
"segments": [],
"smtp": "",
"intervalMs": "",
"daysOfWeek": "",
"timeWindow": "",
"scheduleType": "",
"startAt": "",
"endAt": "",
"triggerWorkflow": true,
"startCampaign": false,
"customAudience": "",
"customSegmentsBool": false,
"segmentsBool": false,
"tagsBool": false,
"categoriesBool": false,
"contactsBool": false
}'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign', {
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "",
"type": "",
"description": "",
"template": "",
"segments": [],
"smtp": "",
"intervalMs": "",
"daysOfWeek": "",
"timeWindow": "",
"scheduleType": "",
"startAt": "",
"endAt": "",
"triggerWorkflow": true,
"startCampaign": false,
"customAudience": "",
"customSegmentsBool": false,
"segmentsBool": false,
"tagsBool": false,
"categoriesBool": false,
"contactsBool": false
}),
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.post(
'/campaign',
{
"name": "",
"type": "",
"description": "",
"template": "",
"segments": [],
"smtp": "",
"intervalMs": "",
"daysOfWeek": "",
"timeWindow": "",
"scheduleType": "",
"startAt": "",
"endAt": "",
"triggerWorkflow": true,
"startCampaign": false,
"customAudience": "",
"customSegmentsBool": false,
"segmentsBool": false,
"tagsBool": false,
"categoriesBool": false,
"contactsBool": false
}
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign',
{
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);
req.write(JSON.stringify(payload));
req.end();
});

const { data } = await send({
"name": "",
"type": "",
"description": "",
"template": "",
"segments": [],
"smtp": "",
"intervalMs": "",
"daysOfWeek": "",
"timeWindow": "",
"scheduleType": "",
"startAt": "",
"endAt": "",
"triggerWorkflow": true,
"startCampaign": false,
"customAudience": "",
"customSegmentsBool": false,
"segmentsBool": false,
"tagsBool": false,
"categoriesBool": false,
"contactsBool": false
});
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/campaign",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"name": "",
"type": "",
"description": "",
"template": "",
"segments": [],
"smtp": "",
"intervalMs": "",
"daysOfWeek": "",
"timeWindow": "",
"scheduleType": "",
"startAt": "",
"endAt": "",
"triggerWorkflow": True,
"startCampaign": False,
"customAudience": "",
"customSegmentsBool": False,
"segmentsBool": False,
"tagsBool": False,
"categoriesBool": False,
"contactsBool": False
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode({
'name': '',
'type': '',
'description': '',
'template': '',
'segments': [],
'smtp': '',
'intervalMs': '',
'daysOfWeek': '',
'timeWindow': '',
'scheduleType': '',
'startAt': '',
'endAt': '',
'triggerWorkflow': true,
'startCampaign': false,
'customAudience': '',
'customSegmentsBool': false,
'segmentsBool': false,
'tagsBool': false,
'categoriesBool': false,
'contactsBool': false
}),
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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.

Response — data is null; the outcome is the status code and message.

cURL
curl -X DELETE 'https://api.leadx.in/api/key/protected/campaign' \
-H 'apikey: $LEADX_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"ids": [
"RESOURCE_ID"
],
"selectAll": false
}'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign', {
method: 'DELETE',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"ids": [
"RESOURCE_ID"
],
"selectAll": false
}),
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.delete(
'/campaign',
{
"ids": [
"RESOURCE_ID"
],
"selectAll": false
}
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign',
{
method: 'DELETE',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);
req.write(JSON.stringify(payload));
req.end();
});

const { data } = await send({
"ids": [
"RESOURCE_ID"
],
"selectAll": false
});
console.log(data);
Python
import os
import requests

res = requests.delete(
"https://api.leadx.in/api/key/protected/campaign",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"ids": [
"RESOURCE_ID"
],
"selectAll": False
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode({
'ids': [
'RESOURCE_ID'
],
'selectAll': false
}),
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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

Response — data is one Campaign object.

cURL
curl -X GET 'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID' \
-H 'apikey: $LEADX_API_KEY'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID', {
method: 'GET',
headers: {
apikey: process.env.LEADX_API_KEY,
},
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.get(
'/campaign/CAMPAIGN_ID'
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID',
{
method: 'GET',
headers: {
apikey: process.env.LEADX_API_KEY,
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);

req.end();
});

const { data } = await send(null);
console.log(data);
Python
import os
import requests

res = requests.get(
"https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID",
headers={"apikey": os.environ["LEADX_API_KEY"]},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
],
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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—

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

cURL
curl -X PUT 'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID' \
-H 'apikey: $LEADX_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"startCampaign": ""
}'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID', {
method: 'PUT',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"startCampaign": ""
}),
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.put(
'/campaign/CAMPAIGN_ID',
{
"startCampaign": ""
}
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID',
{
method: 'PUT',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);
req.write(JSON.stringify(payload));
req.end();
});

const { data } = await send({
"startCampaign": ""
});
console.log(data);
Python
import os
import requests

res = requests.put(
"https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"startCampaign": ""
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode({
'startCampaign': ''
}),
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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

FieldTypeRequiredDefault
namestringyes—

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

cURL
curl -X POST 'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/assignTag' \
-H 'apikey: $LEADX_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"name": ""
}'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/assignTag', {
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": ""
}),
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.post(
'/campaign/CAMPAIGN_ID/assignTag',
{
"name": ""
}
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/assignTag',
{
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);
req.write(JSON.stringify(payload));
req.end();
});

const { data } = await send({
"name": ""
});
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/assignTag",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"name": ""
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/assignTag');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode({
'name': ''
}),
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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

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

cURL
curl -X PUT 'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/continue' \
-H 'apikey: $LEADX_API_KEY'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/continue', {
method: 'PUT',
headers: {
apikey: process.env.LEADX_API_KEY,
},
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.put(
'/campaign/CAMPAIGN_ID/continue'
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/continue',
{
method: 'PUT',
headers: {
apikey: process.env.LEADX_API_KEY,
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);

req.end();
});

const { data } = await send(null);
console.log(data);
Python
import os
import requests

res = requests.put(
"https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/continue",
headers={"apikey": os.environ["LEADX_API_KEY"]},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/continue');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
],
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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.

Response — data 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.

cURL
curl -X GET 'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/logs?p=1&n=25' \
-H 'apikey: $LEADX_API_KEY'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/logs?p=1&n=25', {
method: 'GET',
headers: {
apikey: process.env.LEADX_API_KEY,
},
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.get(
'/campaign/CAMPAIGN_ID/logs?p=1&n=25'
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/logs?p=1&n=25',
{
method: 'GET',
headers: {
apikey: process.env.LEADX_API_KEY,
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);

req.end();
});

const { data } = await send(null);
console.log(data);
Python
import os
import requests

res = requests.get(
"https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/logs?p=1&n=25",
headers={"apikey": os.environ["LEADX_API_KEY"]},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/logs?p=1&n=25');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
],
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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

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

cURL
curl -X PUT 'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/play-pause' \
-H 'apikey: $LEADX_API_KEY'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/play-pause', {
method: 'PUT',
headers: {
apikey: process.env.LEADX_API_KEY,
},
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.put(
'/campaign/CAMPAIGN_ID/play-pause'
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/play-pause',
{
method: 'PUT',
headers: {
apikey: process.env.LEADX_API_KEY,
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);

req.end();
});

const { data } = await send(null);
console.log(data);
Python
import os
import requests

res = requests.put(
"https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/play-pause",
headers={"apikey": os.environ["LEADX_API_KEY"]},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/play-pause');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
],
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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

FieldTypeDefault
statusstring—
pagenumber1
limitnumber50

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

cURL
curl -X GET 'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/recipients' \
-H 'apikey: $LEADX_API_KEY'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/recipients', {
method: 'GET',
headers: {
apikey: process.env.LEADX_API_KEY,
},
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.get(
'/campaign/CAMPAIGN_ID/recipients'
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/recipients',
{
method: 'GET',
headers: {
apikey: process.env.LEADX_API_KEY,
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);

req.end();
});

const { data } = await send(null);
console.log(data);
Python
import os
import requests

res = requests.get(
"https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/recipients",
headers={"apikey": os.environ["LEADX_API_KEY"]},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/recipients');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
],
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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

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

cURL
curl -X POST 'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/retry-failed' \
-H 'apikey: $LEADX_API_KEY'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/retry-failed', {
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
},
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.post(
'/campaign/CAMPAIGN_ID/retry-failed'
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/retry-failed',
{
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);

req.end();
});

const { data } = await send(null);
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/retry-failed",
headers={"apikey": os.environ["LEADX_API_KEY"]},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/retry-failed');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
],
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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

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

cURL
curl -X POST 'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/sync-failed' \
-H 'apikey: $LEADX_API_KEY'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/sync-failed', {
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
},
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.post(
'/campaign/CAMPAIGN_ID/sync-failed'
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/sync-failed',
{
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);

req.end();
});

const { data } = await send(null);
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/sync-failed",
headers={"apikey": os.environ["LEADX_API_KEY"]},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign/CAMPAIGN_ID/sync-failed');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
],
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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

FieldTypeDefault
segmentsarray[]
customAudienceobject{}
cURL
curl -X POST 'https://api.leadx.in/api/key/protected/campaign/audience-preview' \
-H 'apikey: $LEADX_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"segments": [],
"customAudience": {}
}'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign/audience-preview', {
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"segments": [],
"customAudience": {}
}),
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.post(
'/campaign/audience-preview',
{
"segments": [],
"customAudience": {}
}
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign/audience-preview',
{
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);
req.write(JSON.stringify(payload));
req.end();
});

const { data } = await send({
"segments": [],
"customAudience": {}
});
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/campaign/audience-preview",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"segments": [],
"customAudience": {}
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign/audience-preview');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode({
'segments': [],
'customAudience': {}
}),
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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.

Response — data 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.

cURL
curl -X GET 'https://api.leadx.in/api/key/protected/campaign/manual?p=1&n=25' \
-H 'apikey: $LEADX_API_KEY'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign/manual?p=1&n=25', {
method: 'GET',
headers: {
apikey: process.env.LEADX_API_KEY,
},
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.get(
'/campaign/manual?p=1&n=25'
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign/manual?p=1&n=25',
{
method: 'GET',
headers: {
apikey: process.env.LEADX_API_KEY,
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);

req.end();
});

const { data } = await send(null);
console.log(data);
Python
import os
import requests

res = requests.get(
"https://api.leadx.in/api/key/protected/campaign/manual?p=1&n=25",
headers={"apikey": os.environ["LEADX_API_KEY"]},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign/manual?p=1&n=25');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
],
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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

FieldTypeDefault
templateId—
columnMapping—
templateName—
templateSubject—
campaignType—
campaignName—
file—
delaySecondsnumber0

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

cURL
curl -X POST 'https://api.leadx.in/api/key/protected/campaign/manual' \
-H 'apikey: $LEADX_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"templateId": "",
"columnMapping": "",
"templateName": "",
"templateSubject": "",
"campaignType": "",
"campaignName": "",
"file": "",
"delaySeconds": 0
}'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign/manual', {
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"templateId": "",
"columnMapping": "",
"templateName": "",
"templateSubject": "",
"campaignType": "",
"campaignName": "",
"file": "",
"delaySeconds": 0
}),
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.post(
'/campaign/manual',
{
"templateId": "",
"columnMapping": "",
"templateName": "",
"templateSubject": "",
"campaignType": "",
"campaignName": "",
"file": "",
"delaySeconds": 0
}
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign/manual',
{
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);
req.write(JSON.stringify(payload));
req.end();
});

const { data } = await send({
"templateId": "",
"columnMapping": "",
"templateName": "",
"templateSubject": "",
"campaignType": "",
"campaignName": "",
"file": "",
"delaySeconds": 0
});
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/campaign/manual",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"templateId": "",
"columnMapping": "",
"templateName": "",
"templateSubject": "",
"campaignType": "",
"campaignName": "",
"file": "",
"delaySeconds": 0
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign/manual');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode({
'templateId': '',
'columnMapping': '',
'templateName': '',
'templateSubject': '',
'campaignType': '',
'campaignName': '',
'file': '',
'delaySeconds': 0
}),
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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

Response — data is one TempManualCampaign object.

cURL
curl -X GET 'https://api.leadx.in/api/key/protected/campaign/manual/CAMPAIGN_ID' \
-H 'apikey: $LEADX_API_KEY'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign/manual/CAMPAIGN_ID', {
method: 'GET',
headers: {
apikey: process.env.LEADX_API_KEY,
},
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.get(
'/campaign/manual/CAMPAIGN_ID'
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign/manual/CAMPAIGN_ID',
{
method: 'GET',
headers: {
apikey: process.env.LEADX_API_KEY,
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);

req.end();
});

const { data } = await send(null);
console.log(data);
Python
import os
import requests

res = requests.get(
"https://api.leadx.in/api/key/protected/campaign/manual/CAMPAIGN_ID",
headers={"apikey": os.environ["LEADX_API_KEY"]},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign/manual/CAMPAIGN_ID');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
],
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

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

FieldTypeDefault
smtp—
template—
testEmail—
testContactNumberobject{}

Response — data is null; the outcome is the status code and message.

cURL
curl -X POST 'https://api.leadx.in/api/key/protected/campaign/test/TYPE' \
-H 'apikey: $LEADX_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"smtp": "",
"template": "",
"testEmail": "",
"testContactNumber": {}
}'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/campaign/test/TYPE', {
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"smtp": "",
"template": "",
"testEmail": "",
"testContactNumber": {}
}),
});

const payload = await res.json();
if (!res.ok) {
// Errors carry { status, success, message } — not the success envelope.
throw new Error(`${res.status} ${payload.message}`);
}

console.log(payload.data);
axios
import axios from 'axios';

const leadx = axios.create({
baseURL: 'https://api.leadx.in/api/key/protected',
headers: { apikey: process.env.LEADX_API_KEY },
});

try {
const { data } = await leadx.post(
'/campaign/test/TYPE',
{
"smtp": "",
"template": "",
"testEmail": "",
"testContactNumber": {}
}
);
console.log(data.data);
} catch (err) {
// axios throws on 4xx/5xx; the envelope is on err.response.data.
throw new Error(`${err.response?.status} ${err.response?.data?.message ?? err.message}`);
}
Node (no deps)
import { request } from 'node:https';

// The dependency-free version, for somewhere fetch is not available.
const send = (payload) =>
new Promise((resolve, reject) => {
const req = request(
'https://api.leadx.in/api/key/protected/campaign/test/TYPE',
{
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
},
(res) => {
let raw = '';
res.on('data', (chunk) => { raw += chunk; });
res.on('end', () => {
const body = JSON.parse(raw);
if (res.statusCode >= 400) reject(new Error(`${res.statusCode} ${body.message}`));
else resolve(body);
});
},
);
req.on('error', reject);
req.write(JSON.stringify(payload));
req.end();
});

const { data } = await send({
"smtp": "",
"template": "",
"testEmail": "",
"testContactNumber": {}
});
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/campaign/test/TYPE",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"smtp": "",
"template": "",
"testEmail": "",
"testContactNumber": {}
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/campaign/test/TYPE');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'apikey: ' . getenv('LEADX_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode({
'smtp': '',
'template': '',
'testEmail': '',
'testContactNumber': {}
}),
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$payload = json_decode($response, true);
if ($status >= 400) {
throw new RuntimeException("$status {$payload['message']}");
}

print_r($payload['data']);

Errors EmailSendingFailed_500 · EmailTemplateNotFound_404 · InvalidCampaignType_400 · MetaTemplateNotFound_404