Skip to main content

Company

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

2 endpoints.

GET /company​

Get company.

Auth apikey

:::note Used by the web app pages/Billing.jsx, pages/CompanyProfile.jsx :::

Response — data is one Company object.

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

PUT /company​

Update company.

Auth apikey · Success 200

:::note Used by the web app pages/Billing.jsx, pages/CompanyProfile.jsx :::

Response — data is one Feature 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/company' \
-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/company', {
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(
'/company'
);
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/company',
{
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/company",
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/company');
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']);