Serving your own customers
This page is for a platform: an app with its own users, where each user needs their own leads. An agency running outreach for five clients, a vertical SaaS with four hundred tradespeople, a marketplace.
Your platform holds one API key. Each of your users is a workspace on our side — its own leads, its own services, its own budget. Your users never get a LeadCubs account: no signup, no password, nothing to log into.
If you are one business integrating your own leads, you need none of this. Start with Getting started; your account already has one workspace and every key reaches it automatically.
1. Setup, once
In the dashboard: Settings → Integrations → API keys → Create.
- Access: Read & write
- Tick Manage workspaces
That third one is opt-in and off by default, because a key that can create tenants is a platform's key rather than an integration's. Copy the key into your environment; you will not need the dashboard again except to rotate it.
export BASE="https://leadcubs.com/api"
export LEADCUBS_TOKEN="1|gVJm0rE8ZO..."
2. A user signs up: create their workspace
curl -s -X POST "$BASE/workspaces" \
-H "Authorization: Bearer $LEADCUBS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Dupont Paysagiste",
"monthly_credit_limit": 60,
"business_profile": {
"services": [
{ "name": "Lawn care", "price_usd": 120 },
{ "name": "Hedge trimming", "price_usd": 80 },
{ "name": "Patio installation" }
]
}
}'
{ "data": { "id": 41, "name": "Dupont Paysagiste", "monthly_credit_limit": 60 } }
Store 41 against your user. Everything else about them uses it. Your key
is granted the new workspace immediately, so the next call can use it.
services is what makes a lead worth having. Each lead is matched to the
single service that fits its biggest gap, and the outreach angle is written
from that service. Split them by deliverable, not by audience: Lawn care
and Hedge trimming, never Garden services — a blended name cannot be
matched to a specific gap, which is the whole point.
monthly_credit_limit is that user's ration of your shared pool. Credits
are billed to you, not to them, so without a limit one user's wide search can
spend the balance every other user depends on. 60 credits is roughly 30
enriched leads a month. Omit it for no limit.
3. Get them leads
One call per user, whenever your own scheduler says so — Monday morning, or the moment they tap a button.
curl -s -X POST "$BASE/searches" \
-H "Authorization: Bearer $LEADCUBS_TOKEN" \
-H "LeadCubs-Workspace: 41" \
-H "Content-Type: application/json" \
-d '{
"verticals": ["syndic de copropriété", "hôtel", "bureaux"],
"location": "Rennes",
"country_code": "FR",
"limit": 10
}'
{ "data": { "id": 884, "status": "queued", "results_count": 0 } }
202, not 201: the leads arrive a minute or two later. Poll
GET /searches/884 until status is done or failed, then read
GET /leads?search_run_id=884 for that batch alone. See
Asynchronous work.
| Field | |
|---|---|
verticals |
One to five keywords. The limit is split between them, never multiplied, so a search costs the same whatever it looks for |
location |
Required. The town or area, as a place name. It is half the coverage key, so send the same string every time (below) |
limit |
Leads for this search, across all its keywords |
country_code |
Resolves the keywords into the market's language. plumber in France searches plombier |
location_geo |
Optional. A {type, center: {lat, lng}, radius} circle in metres, to start somewhere precise rather than at a geocoded place name. A starting point by default, which the search works outward from |
stay_within_radius |
Makes that circle a hard boundary: nothing outside it is returned or charged. Needs location_geo. Send it if you draw the circle for your own user — see Getting started |
enrich |
false for the listing only — no email, no score, no drafted angle — at 1 credit per result instead of 2, and no business profile needed. Worth it if your users qualify leads themselves |
Nothing standing is left behind. No object to pause, delete or keep being billed for. A user who churns is a user you stop calling for.
An area that runs out is a quiet 0, not a failure. Once every business
around that location has been served to the workspace, the run finishes done
with reason: "exhausted", 0 results and 0 credits — and it recovers by
itself, because the week a new business opens there, the next call picks it up.
Surface it to your user as "no new prospects this week" rather than an empty
screen.
Two things to get right
Pace the calls. Writes are rate limited (see
Rate limits), so four hundred users on a Monday morning wants
a paced worker rather than a burst — it is about fifteen minutes of calling, not
a queue system. Send an Idempotency-Key on each one so a timeout retry cannot
buy the same batch twice.
Store one canonical (keyword, location, radius) per user and send those
bytes unchanged, forever. Coverage is keyed on exactly those three, so
"Rennes" and "Rennes, France" are two separate areas and the second one
re-buys what the first already found. Case and extra spaces are safe; anything
else is not. Deriving the location from user input on every call is the one
mistake here that costs real money, and nothing will warn you.
4. Read the batch
curl -s "$BASE/leads?status=new" \
-H "Authorization: Bearer $LEADCUBS_TOKEN" \
-H "LeadCubs-Workspace: 41"
Each lead carries the business, its contact details, latitude/longitude
where the listing had them, and an opportunity score. See
Getting started for the response shape, for pagination,
and for why search_run_id is a better incremental boundary than a timestamp.
matched_service and the drafted email can both be null, on an enriched
lead that worked. They are the answer to "which of this workspace's services
does this business need, and how would you open that conversation", and
sometimes the answer is none: the business has no gap that this workspace's
services resolve. Scoring a lead and pitching one are separate questions, so
the score is always there. Treat both fields as optional rather than waiting
for them to fill in, because nothing further is coming.
That is most common where the workspace sells something a prospect's website has no bearing on, which is to say most non-digital trades. If your users are in that position and you do not surface our drafts anyway, nothing is lost: the lead, its contacts and its score are unaffected.
5. Record what the user did
curl -s -X PUT "$BASE/leads/41234" \
-H "Authorization: Bearer $LEADCUBS_TOKEN" \
-H "LeadCubs-Workspace: 41" \
-H "Content-Type: application/json" \
-d '{"status": "contacted"}'
Useful statuses: new, contacted, manual_outreach, converted, lost.
notes takes free text.
Radars are not part of the API
A radar is a standing search that runs on a schedule. It exists, the
dashboard is built on it, and it is not reachable with an API key — reading
or writing one answers 403.
Two reasons. A radar is a standing object with a lifecycle somebody has to follow: it completes when its ground runs out, and an integration that does not watch for that leaves its users quietly receiving nothing, with no call ever failing. And a radar is the thing that can make us send mail as the customer, which we are not exposing while a token cannot see a bounce, manage a sending identity or stop a campaign mid-flight.
POST /searches is how an integration produces leads, and it is a better fit
for a platform anyway: nothing standing to reconcile against churn, and an
exhausted area is a 0-result day rather than a state to notice and repair.
If your users want the scheduling rather than your app, they can have their own LeadCubs account and build radars in the dashboard. That is a different product shape from this page, which assumes your users never log in to us.
The one rule
Send LeadCubs-Workspace on every call about a user. That header is the
whole of multi-tenancy.
Omit it and you get a 400 rather than a wrong answer — we refuse to guess,
because guessing would file one customer's leads under another and nothing
downstream would notice:
{ "message": "This token can act on several workspaces. Name one with the LeadCubs-Workspace header.",
"workspaces": [41, 42, 43] }
Assert the workspace you were given. GET /me reports which one answered.
The header is doing its job precisely when it sends you somewhere else, so
check once per user — on first call, or once per loop — that you are where you
meant to be. Nothing else will tell you.
Errors worth handling
| Means | Do | |
|---|---|---|
402 with "workspace_limited": true |
That user hit their ration | Raise it: PATCH /workspaces/41 |
402 without it |
Your pool is empty | Top up. See Credits |
400 naming the header |
It was missing | Send it |
403 naming a workspace limit |
Your plan holds a fixed number of users | Contact us. The limit is per account, so a second key does not widen it |
404 on a workspace |
Not one your key was granted | Check the id |
409 |
That Idempotency-Key is still in flight |
Wait and retry the same key. A new key buys the batch twice |
429 |
Rate limited | Honour Retry-After. See Rate limits |
402, 404 and 422 fail identically on retry. Send an Idempotency-Key on
anything that spends credits so a timeout can be retried safely — see
Errors.
Rotating your key
Create a new key, tick all workspaces, then revoke the old one.
Do it the moment a key might have leaked. A key cannot be granted workspaces after it is created — deliberately, so a leaked key can never widen its own reach — which means rotation is the only way to move access, and the new key must be given the same workspaces before you revoke the old.
Also useful
GET /workspaces— the workspaces your key can act for, which is also what to read when you need a header value.PATCH /workspaces/{id}— rename, or change the credit limit.PUT /workspaces/{id}/business-profile— replace a user's service list when they change what they sell.
Creating workspaces and setting profiles cost no credits. Only finding and enriching leads does.