Asynchronous work
Nothing expensive answers in its own response. A website analysis scrapes a site and runs a model; a search queries a search provider, enriches contacts and scores every result. All of it is queued, and the response tells you where to look rather than what was found.
That is the one pattern to build around. There are two of them, and they differ only in how long you wait and which id you poll.
Website analysis: seconds
POST /website-analyses -> 201, status "analyzing"
GET /website-analyses/{id} -> status "analyzing" | "done" | "failed"
Terminal when status is done or failed. On done, data holds the
report and analyzed_at is set. Measured runs finish in roughly 15 seconds.
for i in $(seq 1 24); do
curl -s -D /tmp/h -o /tmp/b "$BASE/website-analyses/$ID" \
-H "Authorization: Bearer $LEADCUBS_TOKEN" \
-H "Accept: application/json"
wait=$(grep -i '^retry-after:' /tmp/h | tr -dc '0-9')
# No Retry-After means it has settled.
[ -z "$wait" ] && break
sleep "$wait"
done
jq -r .data.status /tmp/b
Read Retry-After rather than picking an interval. Every response from a
job that is still running carries it, in seconds, set from measured durations.
When the work settles the header is gone, and that absence is the stop signal:
you never have to interpret the status string to know when to stop.
Give up after 2 minutes. A run still analyzing after that has almost
certainly failed without recording it, and polling longer will not change the
answer.
One-off search: a minute or two
POST /searches -> 202, status "queued"
GET /searches/{id} -> status "queued" | "running" | "done" | "failed"
GET /leads?search_run_id={id} -> what it found
This is how an integration produces leads. It runs once, leaves no object
behind and never spends again — see Getting started.
Everything below about giving up, about
Retry-After and about leads arriving after the run reports done applies
here unchanged.
results_count is the count so far, not a total: leads appear as they are
found. A run that settles at 0 carries a reason, and the two mean different
things. exhausted is every business in that area already served to you, so a
wider location or a different keyword is the next move; provider is a failure
on their side, and nothing was charged for results that never arrived.
A basic run ("enrich": false) polls identically and settles sooner. The
leads are not enriched or analysed, so there is no per-lead pipeline to wait
on — but still poll rather than assuming, because the provider lookup itself is
what takes the minute. One thing differs once it is done: those leads stay at
status new and their analysis is null, permanently, because nothing is
coming for them. Do not wait on a status change that will never arrive.
Why there is no callback
There are no webhooks on the public API yet, so polling is the only option. The app itself does not poll: it has a WebSocket channel that broadcasts when a run ends, and that channel is authorised per user session rather than per token, so an integration cannot subscribe to it.
Known limitation. There is still no push: no webhooks, and the WebSocket channel is authorised per browser session, so an integration cannot subscribe.
Retry-Aftermakes the loop cheap rather than removing it.A blocking variant was considered and rejected. A held request occupies a worker for its whole duration, and a search takes a minute or two against a 30-second request ceiling, so it could not work for the case that needs it most. Webhooks are the right answer and are not built yet.
Leads are not created synchronously either
A lead arrives new, then moves through the pipeline as jobs process it. The
statuses you will see from the API are new, enriched, contacted,
replied, bounced, converted, lost, and a few more tied to our own
sending integration. GET /leads/{id}/analysis has its own analyzing,
done, failed lifecycle, charged separately.
We never send mail for an API caller. Our sending integrations are a dashboard feature, reached through radars, and radars are not part of the public API — a token cannot see a bounce, manage a sending identity or stop a campaign mid-flight, so having us mail on your users' behalf would be a promise we have no surface to keep. An integration collects the leads and sends them itself.
This used to read: pass "smtp". That was a workaround rather than an
instruction. smtp says the leads will be emailed from our mailbox; nothing
sent only because sending needs an approval an API caller never makes, so it
worked by accident and sat one setting away from emailing your prospects from
our sending profile.