Start Lead Search
Leads
Start Lead Search
Kick off or continue a natural-language lead search. Runs asynchronously.
POST
Start Lead Search
CLI:
See also: Get search task · Get results · AI agent playbook.
Overview
Creates a Search fromprompt plus fetch_count, guarantees a result List, and dispatches the lead-search Trigger.dev task. Repeating the same prompt for the same List continues from the stored search cursor, so the next run returns the next batch instead of the same people again.
The flow is asynchronous: the response returns a task plus list. Poll GET /api/leads/search?taskId={taskId} until the search is terminal, then open the returned List or read raw rows with GET /api/leads/search/results?taskId={taskId}.
Fetches up to 2500 new rows per run (the server clamps fetch_count to that ceiling). Billing happens only for records actually saved.
Binding to a list
SupplyinglistId binds the search to an existing List when the caller owns it. If that id does not exist, the route creates a List with that client-generated id. Omitting listId creates a new result List named from listName or the prompt. Only one active search task per List; a second concurrent POST returns 409.
This operation shares the URL path
/api/leads/search with the read verb. See Get search task to enumerate the caller’s recent searches.AI agent notes
The lead-discovery journey:
- Ask the human for a natural-language
promptand afetch_count. POST /api/leads/searchwith{ prompt, fetch_count }. IncludelistIdonly when you want to populate an existing or client-generated List id.GET /api/leads/search?taskId={taskId}— poll every 5 to 10 s untilstatus === "completed".- Use the response
list.idas the populated result List. Optionally callGET /api/leads/search/results?taskId={taskId}to inspect raw result rows. - To get more people for the same audience, call
POST /api/leads/searchagain with the same prompt and the samelistId.
fetch_countis clamped at 2500 — do not bother asking for more.- Repeating the same normalized prompt continues pagination. Changing the wording creates a new search.
- Lead Search currently returns people. Company details come from the returned person’s current company fields.
status is pending or running. Most runs finish within 2 minutes; give up at 10 minutes and escalate with the correlationId.On 409: another search is active for the list. Wait for it to complete, or DELETE it first.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Natural-language lead search request.
Natural-language description of the leads to find.
Required string length:
1 - 2000Number of new leads to fetch for this run.
Required range:
0 < x <= 2500Optional list to auto-populate when the search completes.
Optional name for the result list. Used when listId is omitted or points to a new client-generated list id.
Required string length:
1 - 120