Skip to main content

Leads

A lead is an enquiry, always attached to a contact. See the Leads guide for the concepts.

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

13 endpoints.

GET /lead​

List leads for the company, with the standard pagination, search and filter contract.

Auth apikey

:::note Used by the web app components/CustomField.jsx, components/GenerateEmailTemplateModal.jsx, components/GenerateWhatsappTemplateModal.jsx and 4 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 Lead objects, alongside the pagination fields described in Response format. (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/lead?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/lead?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(
'/lead?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/lead?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/lead?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/lead?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 /lead​

Create a lead, creating or reusing the contact behind it.

Auth apikey · Success 201

:::note Used by the web app components/CustomField.jsx, components/GenerateEmailTemplateModal.jsx, components/GenerateWhatsappTemplateModal.jsx and 4 more :::

Request body

FieldTypeDefaultNotes
contactId—Attach to an existing contact and skip contact matching.
formDataobject{}System and custom fields together — see Custom fields.
emailstring—Contact email. The default deduplication key.
contactNumberobject{}{ countryCode, number }.
namestring""Contact name.
work_phone_number""{ countryCode, number }.
whatsapp_contact_number""{ countryCode, number }.
sourcestring—Dropped silently if it is not a known source value.
contactDataobject{}Extra fields for the contact being created.
skipInvalid—Keep going past rows that fail validation instead of rejecting the request.

Response — data is one Lead object.

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

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(
'/lead',
{
"contactId": "",
"formData": {},
"email": "",
"contactNumber": {},
"name": "",
"work_phone_number": "",
"whatsapp_contact_number": "",
"source": "",
"contactData": {},
"skipInvalid": ""
}
);
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/lead',
{
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({
"contactId": "",
"formData": {},
"email": "",
"contactNumber": {},
"name": "",
"work_phone_number": "",
"whatsapp_contact_number": "",
"source": "",
"contactData": {},
"skipInvalid": ""
});
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/lead",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"contactId": "",
"formData": {},
"email": "",
"contactNumber": {},
"name": "",
"work_phone_number": "",
"whatsapp_contact_number": "",
"source": "",
"contactData": {},
"skipInvalid": ""
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/lead');
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({
'contactId': '',
'formData': {},
'email': '',
'contactNumber': {},
'name': '',
'work_phone_number': '',
'whatsapp_contact_number': '',
'source': '',
'contactData': {},
'skipInvalid': ''
}),
]);

$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 ContactNotFound_400 · InvalidCustomFieldValue_400 · InvalidCustomField_400 · InvalidSystemField_400 · UniqueKeyInvalid_400

PUT /lead​

Apply one set of changes to many leads.

Auth apikey · Success 200

:::note Used by the web app components/CustomField.jsx, components/GenerateEmailTemplateModal.jsx, components/GenerateWhatsappTemplateModal.jsx and 4 more :::

Request body — the standard bulk selection (ids, nids, selectAll) plus formData and updateType.

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

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(
'/lead',
{
"ids": [
"RESOURCE_ID"
],
"selectAll": false,
"formData": {},
"updateType": "set"
}
);
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/lead',
{
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({
"ids": [
"RESOURCE_ID"
],
"selectAll": false,
"formData": {},
"updateType": "set"
});
console.log(data);
Python
import os
import requests

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

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/lead');
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({
'ids': [
'RESOURCE_ID'
],
'selectAll': false,
'formData': {},
'updateType': 'set'
}),
]);

$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 /lead​

Soft-delete leads (isDeleted: true).

Auth apikey · Success 200

:::note Used by the web app components/CustomField.jsx, components/GenerateEmailTemplateModal.jsx, components/GenerateWhatsappTemplateModal.jsx and 4 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/lead' \
-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/lead', {
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(
'/lead',
{
"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/lead',
{
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/lead",
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/lead');
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 /lead/:id​

Fetch one lead by id.

Auth apikey

:::note Used by the web app components/AILeadGenerationWidget.jsx, components/AILeadGenieWidget.jsx, pages/AILeadGeneration.jsx and 2 more :::

Path parameters

Name
idRequired

Query parameters

FieldDefault
populate—

Response — data is one Lead object.

cURL
curl -X GET 'https://api.leadx.in/api/key/protected/lead/LEAD_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/lead/LEAD_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(
'/lead/LEAD_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/lead/LEAD_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/lead/LEAD_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/lead/LEAD_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 LeadNotFound_404

PUT /lead/:id​

Update lead.

Auth apikey · Success 200 · Emits lead.updated

:::note Used by the web app components/AILeadGenerationWidget.jsx, components/AILeadGenieWidget.jsx, pages/AILeadGeneration.jsx and 2 more :::

Path parameters

Name
idRequired

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

Request body

FieldTypeDefaultNotes
formDataobject{}System and custom fields together — see Custom fields.
tags—Tag ids.
category—Contact category id.

Response — data is one Lead 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/lead/LEAD_ID?p=1&n=25' \
-H 'apikey: $LEADX_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"formData": {},
"tags": "",
"category": ""
}'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/lead/LEAD_ID?p=1&n=25', {
method: 'PUT',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"formData": {},
"tags": "",
"category": ""
}),
});

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(
'/lead/LEAD_ID?p=1&n=25',
{
"formData": {},
"tags": "",
"category": ""
}
);
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/lead/LEAD_ID?p=1&n=25',
{
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({
"formData": {},
"tags": "",
"category": ""
});
console.log(data);
Python
import os
import requests

res = requests.put(
"https://api.leadx.in/api/key/protected/lead/LEAD_ID?p=1&n=25",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"formData": {},
"tags": "",
"category": ""
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/lead/LEAD_ID?p=1&n=25');
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({
'formData': {},
'tags': '',
'category': ''
}),
]);

$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 InvalidCustomFieldValue_400 · InvalidCustomField_400 · InvalidSystemField_400 · LeadNotFound_400

POST /lead/bulk​

Create up to 500 leads in one request, with per-item success and failure.

Auth apikey

Request body

FieldDefaultNotes
formData—System and custom fields together — see Custom fields.
contactId—
contactNumber—
work_phone_number—
whatsapp_contact_number—
email—
name—
skipInvalid—Keep going past rows that fail validation instead of rejecting the request.
cURL
curl -X POST 'https://api.leadx.in/api/key/protected/lead/bulk' \
-H 'apikey: $LEADX_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"formData": "",
"contactId": "",
"contactNumber": "",
"work_phone_number": "",
"whatsapp_contact_number": "",
"email": "",
"name": "",
"skipInvalid": ""
}'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/lead/bulk', {
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"formData": "",
"contactId": "",
"contactNumber": "",
"work_phone_number": "",
"whatsapp_contact_number": "",
"email": "",
"name": "",
"skipInvalid": ""
}),
});

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(
'/lead/bulk',
{
"formData": "",
"contactId": "",
"contactNumber": "",
"work_phone_number": "",
"whatsapp_contact_number": "",
"email": "",
"name": "",
"skipInvalid": ""
}
);
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/lead/bulk',
{
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({
"formData": "",
"contactId": "",
"contactNumber": "",
"work_phone_number": "",
"whatsapp_contact_number": "",
"email": "",
"name": "",
"skipInvalid": ""
});
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/lead/bulk",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"formData": "",
"contactId": "",
"contactNumber": "",
"work_phone_number": "",
"whatsapp_contact_number": "",
"email": "",
"name": "",
"skipInvalid": ""
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/lead/bulk');
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({
'formData': '',
'contactId': '',
'contactNumber': '',
'work_phone_number': '',
'whatsapp_contact_number': '',
'email': '',
'name': '',
'skipInvalid': ''
}),
]);

$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 ContactNotFound_400 · InvalidCustomFieldValue_400 · InvalidCustomField_400 · InvalidSystemField_400 · UniqueKeyInvalid_400

GET /lead/import​

List imports.

Auth apikey

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

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

Create an import from an already-uploaded file.

Auth apikey

Prerequisites

  1. An uploaded file. Register it first and use the returned id as file. POST /upload

Request body

FieldTypeDefaultNotes
file—File id from POST /upload.
headers—The file's header row. Empty → EmptyFile_400.
totalCount—Optional, but must be real if sent. Omitted, rows are counted at run time.
columnMappingobject{}Header name → target field. Values may be system field paths or custom field ids.
optionsobject{}Import behaviour, e.g. skipInvalid.
tagsarray[]Tag ids.
category—Contact category id.
pauseImportbooleantrueDefaults to true — created paused so the mapping can be reviewed.
userEnquiry—

Required: importType, fileId — nested inside another field (commonly formData), or checked under a different internal name, so they do not appear as top-level body fields above.

Response — data is one File 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/lead/import' \
-H 'apikey: $LEADX_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"file": "",
"headers": "",
"totalCount": "",
"columnMapping": {},
"options": {},
"tags": [],
"category": "",
"pauseImport": true,
"userEnquiry": ""
}'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/lead/import', {
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"file": "",
"headers": "",
"totalCount": "",
"columnMapping": {},
"options": {},
"tags": [],
"category": "",
"pauseImport": true,
"userEnquiry": ""
}),
});

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(
'/lead/import',
{
"file": "",
"headers": "",
"totalCount": "",
"columnMapping": {},
"options": {},
"tags": [],
"category": "",
"pauseImport": true,
"userEnquiry": ""
}
);
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/lead/import',
{
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({
"file": "",
"headers": "",
"totalCount": "",
"columnMapping": {},
"options": {},
"tags": [],
"category": "",
"pauseImport": true,
"userEnquiry": ""
});
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/lead/import",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"file": "",
"headers": "",
"totalCount": "",
"columnMapping": {},
"options": {},
"tags": [],
"category": "",
"pauseImport": True,
"userEnquiry": ""
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/lead/import');
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({
'file': '',
'headers': '',
'totalCount': '',
'columnMapping': {},
'options': {},
'tags': [],
'category': '',
'pauseImport': true,
'userEnquiry': ''
}),
]);

$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 EmptyFile_400 · FileNotFound_400 · NoRowsInFile_400

DELETE /lead/import​

Delete imports.

Auth apikey · Success 200

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

Fetch one import, including progress and row errors.

Auth apikey

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

Path parameters

Name
idRequired
cURL
curl -X GET 'https://api.leadx.in/api/key/protected/lead/import/LEAD_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/lead/import/LEAD_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(
'/lead/import/LEAD_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/lead/import/LEAD_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/lead/import/LEAD_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/lead/import/LEAD_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 ImportNotFound_400

PUT /lead/import/:id​

Update an import — this is also how a paused import is resumed.

Auth apikey

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

Path parameters

Name
idRequired

Request body

FieldDefaultNotes
columnMapping—
options—
tags—Tag ids.
category—Contact category id.
userEnquiry—

Required: id — nested inside another field (commonly formData), or checked under a different internal name, so they do not appear as top-level body fields above.

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

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(
'/lead/import/LEAD_ID',
{
"columnMapping": "",
"options": "",
"tags": "",
"category": "",
"userEnquiry": ""
}
);
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/lead/import/LEAD_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({
"columnMapping": "",
"options": "",
"tags": "",
"category": "",
"userEnquiry": ""
});
console.log(data);
Python
import os
import requests

res = requests.put(
"https://api.leadx.in/api/key/protected/lead/import/LEAD_ID",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"columnMapping": "",
"options": "",
"tags": "",
"category": "",
"userEnquiry": ""
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/lead/import/LEAD_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({
'columnMapping': '',
'options': '',
'tags': '',
'category': '',
'userEnquiry': ''
}),
]);

$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 ImportAlreadyPaused_400 · ImportAlreadyRunning_400 · ImportNotFound_400 · InvalidImportStatus_400 · NoRowsInFile_400 · RowFromGreaterThanRowTo_400 · RowFromOutOfRange_400

POST /lead/lead-gen-ai​

Start an AI lead-generation run.

Auth apikey · Success 201

Request body

FieldTypeDefaultNotes
prompt—The outreach goal, in plain language.
requestedCountnumber25
industry""
additionalFiltersobject{}
typestringcontact
aiTypestringgeminiAI provider. Defaults to Gemini.
enrichbooleanfalse
userEnquiryEnabledbooleantrue
cURL
curl -X POST 'https://api.leadx.in/api/key/protected/lead/lead-gen-ai' \
-H 'apikey: $LEADX_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"prompt": "",
"requestedCount": 25,
"industry": "",
"additionalFilters": {},
"type": "contact",
"aiType": "gemini",
"enrich": false,
"userEnquiryEnabled": true
}'
fetch
// Node 18+ and every modern browser ship fetch.
const res = await fetch('https://api.leadx.in/api/key/protected/lead/lead-gen-ai', {
method: 'POST',
headers: {
apikey: process.env.LEADX_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"prompt": "",
"requestedCount": 25,
"industry": "",
"additionalFilters": {},
"type": "contact",
"aiType": "gemini",
"enrich": false,
"userEnquiryEnabled": true
}),
});

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(
'/lead/lead-gen-ai',
{
"prompt": "",
"requestedCount": 25,
"industry": "",
"additionalFilters": {},
"type": "contact",
"aiType": "gemini",
"enrich": false,
"userEnquiryEnabled": true
}
);
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/lead/lead-gen-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": "",
"requestedCount": 25,
"industry": "",
"additionalFilters": {},
"type": "contact",
"aiType": "gemini",
"enrich": false,
"userEnquiryEnabled": true
});
console.log(data);
Python
import os
import requests

res = requests.post(
"https://api.leadx.in/api/key/protected/lead/lead-gen-ai",
headers={"apikey": os.environ["LEADX_API_KEY"]},
json={
"prompt": "",
"requestedCount": 25,
"industry": "",
"additionalFilters": {},
"type": "contact",
"aiType": "gemini",
"enrich": False,
"userEnquiryEnabled": True
},
timeout=30,
)

payload = res.json()
res.raise_for_status()
print(payload["data"])
PHP
<?php
$ch = curl_init('https://api.leadx.in/api/key/protected/lead/lead-gen-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': '',
'requestedCount': 25,
'industry': '',
'additionalFilters': {},
'type': 'contact',
'aiType': 'gemini',
'enrich': false,
'userEnquiryEnabled': true
}),
]);

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