Load leads into a campaign
Put leads into a campaign from JSON or a CSV file, see why any row was skipped, and read the list back.
For AI agents: the docs index is at /llms.txt, and every page is also served as markdown at its URL plus .md.
#What you need
- A key with write scope. Adding leads changes state, so a read key gets
403 forbidden. See Authentication. - A campaign id.
POST /v1/campaignscreates a campaign and returns itsid;GET /v1/campaignslists the ones you have. - Your leads, as objects with an
emailand optionalfirst_name,last_name,company_name,titleandcustom_fields, or as one CSV file.
Both routes take at most 1,000 leads per request. Send larger lists in several requests.
#Optionally verify the addresses first
POST /v1/email-verification checks up to 1,000 addresses per request and spends credits from your wallet. A recent result is reused without a charge. When a fresh check finishes for an address that already belongs to a lead in your account, the result is stored on that lead and shows in its verification field. A lead added afterwards starts as unverified, and a reused result is not copied onto it.
Send an Idempotency-Key header so a retry after a timeout does not pay twice. The same key with a different list of addresses is refused.
curl -X POST https://api.coldagentai.com/v1/email-verification \
-H "Authorization: Bearer $COLDAGENTAI_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: verify-2026-10-18-batch-1" \
-d '{ "emails": ["ada@example.com", "grace@example.org"] }'const base = 'https://api.coldagentai.com';
const headers = { Authorization: `Bearer ${process.env.COLDAGENTAI_API_KEY}`, 'Content-Type': 'application/json' };
async function call(method, path, body) {
const res = await fetch(base + path, { method, headers, body: body === undefined ? undefined : JSON.stringify(body) });
const json = await res.json();
if (!res.ok) throw new Error(`${json.error.code}: ${json.error.fix}`);
return json;
}
const batch = await fetch(base + '/v1/email-verification', {
method: 'POST',
headers: { ...headers, 'Idempotency-Key': 'verify-2026-10-18-batch-1' },
body: JSON.stringify({ emails: ['ada@example.com', 'grace@example.org'] }),
}).then((r) => r.json());
const sendable = batch.results.filter((r) => r.outcome === 'verified' && r.sendable).map((r) => r.email);
console.log(sendable, batch.credits_charged, batch.stopped_by);Each result has an outcome of verified, failed or skipped. Only a verified result carries a result and a sendable flag. invalid, risky and unknown addresses are never sendable. If the wallet runs dry part way, stopped_by is insufficient_credits and the rest are skipped. GET /v1/email-verification/{id} reads a finished batch back without spending anything.
#Add leads as JSON
POST /v1/campaigns/{id}/leads takes a leads array. Addresses are compared case-insensitively against the rest of the request and against your account. A bad row never fails the others.
curl -X POST https://api.coldagentai.com/v1/campaigns/$CAMPAIGN_ID/leads \
-H "Authorization: Bearer $COLDAGENTAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"leads": [
{ "email": "ada@example.com", "first_name": "Ada", "company_name": "Analytical Engines", "custom_fields": { "city": "London" } },
{ "email": "grace@example.org", "first_name": "Grace" }
]
}'const base = 'https://api.coldagentai.com';
const headers = { Authorization: `Bearer ${process.env.COLDAGENTAI_API_KEY}`, 'Content-Type': 'application/json' };
async function call(method, path, body) {
const res = await fetch(base + path, { method, headers, body: body === undefined ? undefined : JSON.stringify(body) });
const json = await res.json();
if (!res.ok) throw new Error(`${json.error.code}: ${json.error.fix}`);
return json;
}
const result = await call('POST', `/v1/campaigns/${process.env.CAMPAIGN_ID}/leads`, {
leads: [
{ email: 'ada@example.com', first_name: 'Ada', company_name: 'Analytical Engines', custom_fields: { city: 'London' } },
{ email: 'grace@example.org', first_name: 'Grace' },
],
});
console.log(result.created, result.updated, result.duplicates, result.rejected);A custom_fields key must start with a letter and use only letters, digits and underscores. Each custom field is usable as a merge field in the sequence.
#Import a CSV file
POST /v1/campaigns/{id}/leads/import takes the file text as the request body with Content-Type: text/plain. A file can hold at most 1,000 data rows, and the request body is limited to 256 KB; a larger body is refused with payload_too_large. The first row is the header, and the email column is found by its name. First name, last name, company and title are mapped from their usual headers, and every other column becomes a custom field.
- Add
?layout=smartleadto read an export with that layout; its activity columns are skipped. - A cell that starts with
=,+,-or@is kept as text and counted inflagged_cells, so you know it could act as a formula if you write it back to a spreadsheet. - Rows the parser itself refused come back in
csv_rejectedwith their line number. Nothing from a file that cannot be read at all is stored.
curl -X POST https://api.coldagentai.com/v1/campaigns/$CAMPAIGN_ID/leads/import \
-H "Authorization: Bearer $COLDAGENTAI_API_KEY" \
-H "Content-Type: text/plain" \
--data-binary @leads.csvimport { readFile } from 'node:fs/promises';
const base = 'https://api.coldagentai.com';
const csv = await readFile('leads.csv', 'utf8');
const res = await fetch(`${base}/v1/campaigns/${process.env.CAMPAIGN_ID}/leads/import`, {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.COLDAGENTAI_API_KEY}`, 'Content-Type': 'text/plain' },
body: csv,
});
const result = await res.json();
if (!res.ok) throw new Error(`${result.error.code}: ${result.error.fix}`);
console.log(result.created, result.rejected, result.csv_rejected, result.flagged_cells, result.warnings);#Read the result
Both routes return the counts and an entry in rows for each row they processed. On the JSON route, index is the position in your leads array, starting at 0. On CSV import, index counts only the rows the parser accepted, so use csv_rejected[].line for refused rows and match the others by email.
| Outcome | Meaning | What to do |
|---|---|---|
created | A new lead was stored and enrolled in this campaign. | Nothing. |
updated | The address was already in your account. The fields you sent were applied and the lead was enrolled in this campaign. | Nothing, unless you did not mean to overwrite its fields. |
duplicate | The address repeats an earlier row in the same request. | Remove the repeat from your source list. |
rejected | The row was not added. reason says why in plain words. | See the reasons below. |
Why a row is rejected
- The address is not a valid email address.
- A field value is too long, or the lead would end up with too many custom fields.
- The address is on your do-not-contact list, either by an entry you added or because the person opted out.
GET /v1/blocklistshows the entries. Entries that record an opt-out cannot be removed. - The address is new to your account and the plan's active-contact cap is already reached. Addresses that are already in your account are not blocked by the cap. Leads that are unsubscribed, bounced or blocked do not count toward it.
Read the list back
GET /v1/campaigns/{id}/leads returns the enrolled leads oldest first. Filter with status (new, contacted, replied, interested, meeting_booked, not_interested, bounced, unsubscribed or blocked). limit goes up to 100; pass next_cursor as cursor for the next page. See Pagination.
curl "https://api.coldagentai.com/v1/campaigns/$CAMPAIGN_ID/leads?status=new&limit=50" \
-H "Authorization: Bearer $COLDAGENTAI_API_KEY"const base = 'https://api.coldagentai.com';
const headers = { Authorization: `Bearer ${process.env.COLDAGENTAI_API_KEY}`, 'Content-Type': 'application/json' };
async function call(method, path, body) {
const res = await fetch(base + path, { method, headers, body: body === undefined ? undefined : JSON.stringify(body) });
const json = await res.json();
if (!res.ok) throw new Error(`${json.error.code}: ${json.error.fix}`);
return json;
}
let cursor;
do {
const query = new URLSearchParams({ status: 'new', limit: '50', ...(cursor ? { cursor } : {}) });
const page = await call('GET', `/v1/campaigns/${process.env.CAMPAIGN_ID}/leads?${query}`);
for (const lead of page.data) console.log(lead.email, lead.status, lead.verification);
cursor = page.next_cursor ?? undefined;
} while (cursor);#What can go wrong
| Code | Cause | Fix |
|---|---|---|
forbidden | The key has read scope. | Use a write key. |
unknown_product | The campaign id is not in your account. | List campaigns with GET /v1/campaigns and use one of those ids. |
invalid_input | The body is not valid, a batch is larger than 1,000, or the CSV has no email column. | Read error.message and error.fix, correct the request and send it again. Nothing was stored. |
payload_too_large | The request body is over the size limit. | Split the list into smaller requests. |
rate_limited | Too many requests for this key. | Wait Retry-After seconds. See Rate limits. |
insufficient_credits | Verification needs more credits than the wallet holds. | Add credits, or send a smaller batch. |
provider_unavailable | Verification has no provider that can run on this server. | Read GET /v1/capabilities, slot verifiers. |
#Next steps
- Set the sequence with
PUT /v1/campaigns/{id}/sequence, preview a step against a real lead withPOST /v1/campaigns/{id}/preview, then start withPOST /v1/campaigns/{id}/start. See Campaigns. - Move a lead to a new status with
PATCH /v1/leads/{id}. See Leads. - Add addresses you never want to mail with
POST /v1/blocklist. See Do-not-contact list.