Skip to main content

Templates

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

13 endpoints.

GET /template/category/:panel​

Get email categories.

Auth apikey

:::note Used by the web app components/GenerateEmailTemplateModal.jsx, components/GenerateWhatsappTemplateModal.jsx, pages/AddEmailTemplate.jsx and 1 more :::

Path parameters

Name
panelRequired

Response — data is one Category object.

cURL
curl -X GET 'https://api.leadx.in/api/key/protected/template/category/PANEL' \
-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/template/category/PANEL', {
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(
'/template/category/PANEL'
);
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/template/category/PANEL',
{
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/template/category/PANEL",
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/template/category/PANEL');
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 InvalidPanel_400

GET /template/email​

Get all email template.

Auth apikey

:::note Used by the web app components/EmailMessageSend.jsx, components/EmailTemplateModal.jsx, pages/AddEmailTemplate.jsx and 9 more :::

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 EmailTemplate 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/template/email?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/template/email?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(
'/template/email?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/template/email?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/template/email?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/template/email?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 /template/email​

Create email template.

Auth apikey · Success 201

:::note Used by the web app components/EmailMessageSend.jsx, components/EmailTemplateModal.jsx, pages/AddEmailTemplate.jsx and 9 more :::

Request body

FieldTypeRequiredDefaultNotes
namestring—
subjectstringyes—
bodystringyes—
categorystring—Contact category id.
attachmentsObjectId[] -> File[]
variablesobject[][]

Required: templateName, subject, body. Of these, templateName is nested inside another field (commonly formData), or checked under a different internal name.

Response — data is one EmailTemplate object.

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

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(
'/template/email',
{
"name": "",
"subject": "",
"body": "",
"category": "",
"attachments": [],
"variables": []
}
);
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/template/email',
{
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": "",
"subject": "",
"body": "",
"category": "",
"attachments": [],
"variables": []
});
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/template/email",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"name": "",
"subject": "",
"body": "",
"category": "",
"attachments": [],
"variables": []
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/template/email');
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': '',
'subject': '',
'body': '',
'category': '',
'attachments': [],
'variables': []
}),
]);

$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 TemplateNameAlreadyExists_400

DELETE /template/email​

Delete email template.

Auth apikey · Success 200

:::note Used by the web app components/EmailMessageSend.jsx, components/EmailTemplateModal.jsx, pages/AddEmailTemplate.jsx and 9 more :::

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/template/email' \
-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/template/email', {
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(
'/template/email',
{
"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/template/email',
{
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/template/email",
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/template/email');
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 /template/email/:id​

Get email template.

Auth apikey

:::note Used by the web app components/GenerateEmailTemplateModal.jsx, pages/AddEmailTemplate.jsx :::

Path parameters

Name
idRequired

Response — data is one EmailTemplate object.

cURL
curl -X GET 'https://api.leadx.in/api/key/protected/template/email/TEMPLATE_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/template/email/TEMPLATE_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(
'/template/email/TEMPLATE_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/template/email/TEMPLATE_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/template/email/TEMPLATE_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/template/email/TEMPLATE_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 EmailTemplateNotFound_404

PUT /template/email/:id​

Update email template.

Auth apikey · Success 200

:::note Used by the web app components/GenerateEmailTemplateModal.jsx, pages/AddEmailTemplate.jsx :::

Path parameters

Name
idRequired

Request body

FieldTypeDefaultNotes
namestring—
subjectstring—
bodystring—
categorystring—Contact category id.
attachmentsObjectId[] -> File—
variablesobject[]—

Response — data is one EmailTemplate object.

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

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(
'/template/email/TEMPLATE_ID',
{
"name": "",
"subject": "",
"body": "",
"category": "",
"attachments": "",
"variables": ""
}
);
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/template/email/TEMPLATE_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({
"name": "",
"subject": "",
"body": "",
"category": "",
"attachments": "",
"variables": ""
});
console.log(data);
Python
import os
import requests

res = requests.put(
"https://api.leadx.in/api/key/protected/template/email/TEMPLATE_ID",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"name": "",
"subject": "",
"body": "",
"category": "",
"attachments": "",
"variables": ""
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/template/email/TEMPLATE_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({
'name': '',
'subject': '',
'body': '',
'category': '',
'attachments': '',
'variables': ''
}),
]);

$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 EmailTemplateNotFound_404 · TemplateNameAlreadyExists_400

POST /template/email/generate-ai​

Generate AI email template.

Auth apikey · Success 201

Request body

FieldDefaultNotes
prompt—The outreach goal, in plain language.
name—
category—Contact category id.
contactIds—
leadIds—
tone—Free text, e.g. friendly or formal.
language—
aiType—AI provider. Defaults to Gemini.
cURL
curl -X POST 'https://api.leadx.in/api/key/protected/template/email/generate-ai' \
-H 'apikey: $LEADX_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"prompt": "",
"name": "",
"category": "",
"contactIds": "",
"leadIds": "",
"tone": "",
"language": "",
"aiType": ""
}'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/template/email/generate-ai', {
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"prompt": "",
"name": "",
"category": "",
"contactIds": "",
"leadIds": "",
"tone": "",
"language": "",
"aiType": ""
}),
});

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(
'/template/email/generate-ai',
{
"prompt": "",
"name": "",
"category": "",
"contactIds": "",
"leadIds": "",
"tone": "",
"language": "",
"aiType": ""
}
);
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/template/email/generate-ai',
{
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({
"prompt": "",
"name": "",
"category": "",
"contactIds": "",
"leadIds": "",
"tone": "",
"language": "",
"aiType": ""
});
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/template/email/generate-ai",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"prompt": "",
"name": "",
"category": "",
"contactIds": "",
"leadIds": "",
"tone": "",
"language": "",
"aiType": ""
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/template/email/generate-ai');
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({
'prompt': '',
'name': '',
'category': '',
'contactIds': '',
'leadIds': '',
'tone': '',
'language': '',
'aiType': ''
}),
]);

$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 /template/whatsapp​

Get all WhatsApp template.

Auth apikey

:::note Used by the web app components/WhatsappMessageSend.jsx, components/WhatsappTemplateModal.jsx, pages/AddLead.jsx and 8 more :::

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 MetaTemplate objects, alongside the pagination fields described in Response format. app is populated, so it arrives as nested objects rather than ids.

cURL
curl -X GET 'https://api.leadx.in/api/key/protected/template/whatsapp?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/template/whatsapp?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(
'/template/whatsapp?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/template/whatsapp?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/template/whatsapp?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/template/whatsapp?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 /template/whatsapp​

Create WhatsApp template.

Auth apikey · Success 201

:::note Used by the web app components/WhatsappMessageSend.jsx, components/WhatsappTemplateModal.jsx, pages/AddLead.jsx and 8 more :::

Request body

FieldTypeDefaultNotes
appID—
namestring—
appCategory—
language—
categorystring—Contact category id.
bodyText—
expiry—
variablesobject[]—
buttonsarray[]
headerType—
headerText—
headerFile—
footerText—
ttl—
addSecurity—
copyCodeText—
refIdsarray[]
defaultsobject{}

Response — data is one Category 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/template/whatsapp' \
-H 'apikey: $LEADX_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"appID": "",
"name": "",
"appCategory": "",
"language": "",
"category": "",
"bodyText": "",
"expiry": "",
"variables": "",
"buttons": [],
"headerType": "",
"headerText": "",
"headerFile": "",
"footerText": "",
"ttl": "",
"addSecurity": "",
"copyCodeText": "",
"refIds": [],
"defaults": {}
}'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/template/whatsapp', {
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"appID": "",
"name": "",
"appCategory": "",
"language": "",
"category": "",
"bodyText": "",
"expiry": "",
"variables": "",
"buttons": [],
"headerType": "",
"headerText": "",
"headerFile": "",
"footerText": "",
"ttl": "",
"addSecurity": "",
"copyCodeText": "",
"refIds": [],
"defaults": {}
}),
});

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(
'/template/whatsapp',
{
"appID": "",
"name": "",
"appCategory": "",
"language": "",
"category": "",
"bodyText": "",
"expiry": "",
"variables": "",
"buttons": [],
"headerType": "",
"headerText": "",
"headerFile": "",
"footerText": "",
"ttl": "",
"addSecurity": "",
"copyCodeText": "",
"refIds": [],
"defaults": {}
}
);
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/template/whatsapp',
{
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({
"appID": "",
"name": "",
"appCategory": "",
"language": "",
"category": "",
"bodyText": "",
"expiry": "",
"variables": "",
"buttons": [],
"headerType": "",
"headerText": "",
"headerFile": "",
"footerText": "",
"ttl": "",
"addSecurity": "",
"copyCodeText": "",
"refIds": [],
"defaults": {}
});
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/template/whatsapp",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"appID": "",
"name": "",
"appCategory": "",
"language": "",
"category": "",
"bodyText": "",
"expiry": "",
"variables": "",
"buttons": [],
"headerType": "",
"headerText": "",
"headerFile": "",
"footerText": "",
"ttl": "",
"addSecurity": "",
"copyCodeText": "",
"refIds": [],
"defaults": {}
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/template/whatsapp');
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({
'appID': '',
'name': '',
'appCategory': '',
'language': '',
'category': '',
'bodyText': '',
'expiry': '',
'variables': '',
'buttons': [],
'headerType': '',
'headerText': '',
'headerFile': '',
'footerText': '',
'ttl': '',
'addSecurity': '',
'copyCodeText': '',
'refIds': [],
'defaults': {}
}),
]);

$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']);

DELETE /template/whatsapp​

Delete WhatsApp template.

Auth apikey · Success 200

:::note Used by the web app components/WhatsappMessageSend.jsx, components/WhatsappTemplateModal.jsx, pages/AddLead.jsx and 8 more :::

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/template/whatsapp' \
-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/template/whatsapp', {
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(
'/template/whatsapp',
{
"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/template/whatsapp',
{
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/template/whatsapp",
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/template/whatsapp');
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 /template/whatsapp/:id​

Get WhatsApp template.

Auth apikey

:::note Used by the web app components/GenerateWhatsappTemplateModal.jsx, pages/AddWhatsappTemplate.jsx, pages/TemplateWhatsapp.jsx :::

Path parameters

Name
idRequired

Response — data is one MetaTemplate object. app is populated, so it arrives as nested objects rather than ids.

cURL
curl -X GET 'https://api.leadx.in/api/key/protected/template/whatsapp/TEMPLATE_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/template/whatsapp/TEMPLATE_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(
'/template/whatsapp/TEMPLATE_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/template/whatsapp/TEMPLATE_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/template/whatsapp/TEMPLATE_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/template/whatsapp/TEMPLATE_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 WhatsAppTemplateNotFound_404

POST /template/whatsapp/generate-ai​

Generate AI WhatsApp template.

Auth apikey · Success 201

Request body

FieldTypeDefaultNotes
prompt—The outreach goal, in plain language.
namestring—
appID—
appCategorystring—
metaCategory—
languagestring—
tone—Free text, e.g. friendly or formal.
contactIds—
leadIds—
aiType—AI provider. Defaults to Gemini.
components—
headerFileObjectId—

Response — data is one MetaTemplate object.

cURL
curl -X POST 'https://api.leadx.in/api/key/protected/template/whatsapp/generate-ai' \
-H 'apikey: $LEADX_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"prompt": "",
"name": "",
"appID": "",
"appCategory": "",
"metaCategory": "",
"language": "",
"tone": "",
"contactIds": "",
"leadIds": "",
"aiType": "",
"components": "",
"headerFile": ""
}'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/template/whatsapp/generate-ai', {
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"prompt": "",
"name": "",
"appID": "",
"appCategory": "",
"metaCategory": "",
"language": "",
"tone": "",
"contactIds": "",
"leadIds": "",
"aiType": "",
"components": "",
"headerFile": ""
}),
});

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(
'/template/whatsapp/generate-ai',
{
"prompt": "",
"name": "",
"appID": "",
"appCategory": "",
"metaCategory": "",
"language": "",
"tone": "",
"contactIds": "",
"leadIds": "",
"aiType": "",
"components": "",
"headerFile": ""
}
);
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/template/whatsapp/generate-ai',
{
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({
"prompt": "",
"name": "",
"appID": "",
"appCategory": "",
"metaCategory": "",
"language": "",
"tone": "",
"contactIds": "",
"leadIds": "",
"aiType": "",
"components": "",
"headerFile": ""
});
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/template/whatsapp/generate-ai",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"prompt": "",
"name": "",
"appID": "",
"appCategory": "",
"metaCategory": "",
"language": "",
"tone": "",
"contactIds": "",
"leadIds": "",
"aiType": "",
"components": "",
"headerFile": ""
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/template/whatsapp/generate-ai');
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({
'prompt': '',
'name': '',
'appID': '',
'appCategory': '',
'metaCategory': '',
'language': '',
'tone': '',
'contactIds': '',
'leadIds': '',
'aiType': '',
'components': '',
'headerFile': ''
}),
]);

$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 /template/whatsapp/status-reconcile​

Reconcile whatsapp template.

Auth apikey · Success 200

Request body

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

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(
'/template/whatsapp/status-reconcile',
{
"tids": "",
"syncAll": ""
}
);
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/template/whatsapp/status-reconcile',
{
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({
"tids": "",
"syncAll": ""
});
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/template/whatsapp/status-reconcile",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"tids": "",
"syncAll": ""
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/template/whatsapp/status-reconcile');
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({
'tids': '',
'syncAll': ''
}),
]);

$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 WhatsAppTemplateNotFound_404