KLCTDevelopers

Send leads into KLCT

View as Markdown

Use this when a lead vendor, a form tool, an ad platform or one of your own scripts needs to push leads into a KLCT account. It is one endpoint, POST /leads/ingest, and it works the same for every account.

How the hand-off works

  1. The KLCT account owner opens Integrations → Connected apps, presses Create API key, names it after the sender and switches on Create and update contacts. KLCT shows the key once, with ready-to-send instructions. The key belongs to that one account, so every lead the sender pushes lands there and nowhere else.
  2. The sender posts batches of leads with that key.
  3. KLCT creates new contacts, tops up ones it already knows, stamps where each came from and puts them on a list.

Make one key per sender. Each is listed on Connected apps with what it has sent and why leads were refused, and can be paused, rotated or revoked on its own, so cutting off one supplier never touches another.

The payload is a contract

Send the fields in the table below and nothing else. KLCT refuses what it does not define instead of ignoring it, so a typo such as list_nmae is reported on your first call and never silently files leads nowhere.

  • An unknown field on a lead rejects that lead (unknown_field) and the rest of the batch is still saved. An unknown field on the call rejects the whole request with 422.
  • Your own data goes in metadata, the one free-form field: flat keys, at most 30, text, number or true/false values of at most 500 characters. A few keys are reserved because KLCT reads them itself (source, ad_attribution, and anything starting ad_, ig_, fb_, wa_, meta_, support_, system_, social_; also lead_vendor, external_id, ingested_via).
  • Every refusal has the same shape: error (the first problem) and issues, a list of {field, code, message}. Leads that were skipped carry their own issues inside errors.

Check your payload first: dry run

Add "dry_run": true to any call to validate it. Leads are checked and matched exactly as for real, the response tells you which would be created or updated, and nothing is saved, put on a list or started. Remove the flag to send for real.

The shortest useful call

curl -X POST "https://app.klctai.com/api/leads/ingest" \
  -H "Authorization: Bearer $KLCT_API_KEY" \
  -H "Idempotency-Key: acme-2026-10-29-batch-1" \
  -H "Content-Type: application/json" \
  -d '{
    "vendor": "Acme Leads",
    "lead_source": "partner",
    "list_name": "Acme Leads — October",
    "tags": ["roofing"],
    "leads": [
      { "email": "[email protected]", "phone": "+15551234567", "name": "Dana", "last_name": "Cole", "external_id": "L-88213",
        "metadata": { "budget": "10-20k", "timeline": "this quarter" } }
    ]
  }'
{
  "created": 1, "updated": 0,
  "results": [{ "index": 0, "status": "created", "contact_id": 90412, "list_id": 12 }],
  "errors": []
}

What each field does

Field Where What it does
leads call 1 to 200 leads. For a single lead you may put its fields at the top level instead.
email, phone lead Match keys, tried in that order. A lead needs at least one. Phones in any common format are stored as E.164.
lead_source call or lead Where the lead came from. Defaults to partner. Values: meta_ads, google_ads, tiktok_ads, website, social_organic, referral, outbound, event, partner, other. Reserve meta_ads and google_ads for leads that really came from those ads: a verdict on them is reported back to the ad platform.
vendor call The supplier's name. Saved on each contact (metadata.lead_vendor) and added as a vendor: … tag so the account can filter by supplier.
external_id lead The lead's id in the sender's system, kept in metadata.external_id.
campaign call or lead The campaign the lead belongs to. A lead's own value overrides the call's.
source_url lead The page or form the lead was captured on (a full URL).
submitted_at lead When the lead signed up on your side, ISO 8601.
utm_source, utm_medium, utm_campaign, utm_term, utm_content lead Standard UTM values.
consent lead The permission that came with the lead: { "given": true, "at": "…", "text": "…", "source_url": "…", "ip": "…" }. given is required; send false if they were asked and declined.
list_id / list_name call or lead Put the lead on a list. list_name is found, or created if it does not exist. A lead's own value overrides the call's.
tags call or lead Added to the contact. Up to 10, 50 characters each.
metadata lead Anything else worth keeping, as flat key/value pairs (see above). Merged into the contact; keys already there win.
dry_run call true validates and matches without saving anything.
trigger_automations call Default true: a lead newly added to a list starts any sequence whose trigger is contact added to this list. Send false to file leads without starting anything.

What KLCT keeps about where a lead came from

Every call adds an arrival record to the contact (metadata.lead_touches): your vendor, the external_id, lead_source, campaign, source_url, the utm_* values, submitted_at, the consent you sent and the time KLCT received it.

  • A person sent by a second supplier gets a second record. The first supplier's record, and metadata.lead_vendor, stay as the original source.
  • The same lead sent twice in a row is recorded once. The last 20 records are kept.
  • consent is stored as you sent it, as evidence. KLCT does not check it and does not stop outreach because of it: that stays your responsibility.

See what was sent

Every real call is logged for 90 days (dry runs are not). GET /leads/ingests returns the calls newest first, with the vendor, the key that made the call, the HTTP status, how many leads were created, topped up or refused, and up to 20 of the errors. Use it to confirm a supplier's batch arrived and to see why rows were refused. It needs the contacts:read scope.

Duplicates and re-sends

  • A lead whose email (or, failing that, phone) matches an existing contact updates that contact. Blank fields are filled; names, status, verdicts and a lead source someone already set are never overwritten; tags are added and metadata is merged.
  • Re-sending the same lead is safe. Someone already on the list is not enrolled in its sequences a second time.
  • Send an Idempotency-Key header with each batch. If a request times out, repeat it with the same key and body: within 24 hours you get the first answer back (Idempotent-Replay: true) and nothing runs again.
  • The same key with a different body is refused (422, idempotency_key_reused): use a new key for new work. If the first request is still running you get 409; wait a few seconds and retry. Only a successful answer is remembered, so a call that returned 422 can be fixed and resent with the same key.
  • Rows that fail validation appear in errors with their index and issues; the others are still saved, and the call still returns 200, so check errors as well as the status. If every row fails the call returns 422.
  • A 429 means too many calls: wait for the Retry-After header and retry.

Choosing the list

Ask the account owner which list the leads belong on. List ids come from GET /contactslists/list. Passing list_name is simpler for a vendor, because the list is created the first time and reused after. One call can create at most 5 new lists by name, so a typo in a per-lead list_name cannot fill the account with lists; send the list_id when you need more. Leads also join any smart (filtered) list of the account that they match.

Good practice for senders

  • Send in batches of 100 to 200, not one request per lead. The limit is 30 calls a minute.
  • Phone numbers are matched on their stored form (+15551234567). A contact whose phone was saved in another format can be missed, so send the email too whenever you have it.
  • Tags are trimmed and Roofing and roofing count as one. A call allows 10 tags and each lead 10 more, plus the vendor: tag.
  • Only send leads you have the right to contact. KLCT does not check consent for you: calls, texts and emails to purchased leads are subject to TCPA, CAN-SPAM and local rules, and the account is responsible for them. If a list has an active sequence, leads put on it will be contacted.
  • Keep the API key on your server. Never put it in a browser page or an app.

Import from a script in 15 lines

import os, uuid, requests

def push(leads, batch_id):
    r = requests.post(
        "https://app.klctai.com/api/leads/ingest",
        headers={"Authorization": f"Bearer {os.environ['KLCT_API_KEY']}", "Idempotency-Key": batch_id},
        json={"vendor": "Acme Leads", "list_name": "Acme Leads — October", "leads": leads},
        timeout=30,
    )
    r.raise_for_status()
    return r.json()

for n in range(0, len(all_leads), 200):
    print(push(all_leads[n:n + 200], f"acme-oct-{n}"))

Import from Node.js or PHP

// Node 18+ (built-in fetch)
async function push(leads, batchId) {
  const res = await fetch("https://app.klctai.com/api/leads/ingest", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.KLCT_API_KEY}`,
      "Idempotency-Key": batchId,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ vendor: "Acme Leads", list_name: "Acme Leads — October", leads }),
  });
  if (res.status === 429) throw new Error(`Rate limited, retry in ${res.headers.get("Retry-After")}s`);
  const body = await res.json();
  if (!res.ok) throw new Error(JSON.stringify(body.issues ?? body));
  if (body.errors.length) console.warn("Some leads were refused", body.errors);
  return body;
}
<?php
$ch = curl_init('https://app.klctai.com/api/leads/ingest');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer '.getenv('KLCT_API_KEY'),
        'Idempotency-Key: acme-oct-batch-1',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode(['vendor' => 'Acme Leads', 'list_name' => 'Acme Leads — October', 'leads' => $leads]),
]);
$body = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);

Postman, Insomnia and other API clients

Import https://app.klctai.com/developers/openapi.json. Every operation, including ingestLeads and listLeadIngests, comes with its fields and a sample body. Add your key as a Bearer token, and send "dry_run": true first.

Connecting Zapier, Make and Facebook Lead Ads

Tools that cannot send our structure themselves are connected through a step that builds it. See Connect lead sources for Zapier, Make, Facebook Lead Ads and form tools.

Building this with an AI coding tool? See Build with AI coding tools.