An AI sales agent is a loop. A model reads a goal, calls tools to fetch data or act, checks the result and stops when a rule says so. Everything else is packaging.
This guide sits in the LeadOcean blog and builds the smallest useful version: an agent that sizes a market, pulls ten prospects and enriches one. You will see each call and its output.
TL;DR
- An agent is a model plus tools plus a stop rule. The data tool decides how good it is.
- This build takes about 30 minutes and spends about 10 of your 1,000 free records.
- Sizing a list is free. Only returned people cost a record.
Prerequisites
- A free LeadOcean account and API key, exported as
$LEADOCEAN_API_KEY(sign up, no card). curlandjqfor the raw calls.- Claude Code, or any MCP client, for the agent version. LeadOcean's hosted MCP server is at
https://api.leadocean.io/mcpand uses OAuth sign-in, so no key is pasted.
Step 1: Understand the loop
Every sales agent runs the same four moves. Observe the goal. Pick a tool. Read the result. Decide whether to continue.
goal: find 10 VPs of Sales at US companies with 51-200 staff
loop:
1. count_leads(filters) -> is the list big enough? (free)
2. search_leads(filters, 10) -> fetch rows (1 record each)
3. get_lead(person_id) -> enrich the best one (1 record)
4. stop when 10 rows are held or the budget is spentThe model does the picking. The tools do the work. Your stop rule is what keeps it from spending records on a loop.
Step 2: Give the agent a data tool
Connect the MCP server so the model can call LeadOcean tools itself. In Claude Code the command is:
claude mcp add --transport http leadocean https://api.leadocean.io/mcpClaude Code's MCP docs (September 2026) describe this --transport http form. Then run /mcp in Claude Code, pick leadocean and authenticate in the browser. The full setup is on the Claude Code MCP page. There are 13 tools. leadocean_count_leads, leadocean_count_companies, leadocean_list_filters, leadocean_list_enum_values, leadocean_get_account and the export status tools are free. Search, lead, phone and company lookups cost one record per person or company returned.
Step 3: Size the market before spending anything
Ask the free count first. An agent that skips this step burns records on empty or huge lists.
curl -s -X POST "https://api.leadocean.io/v1/people/search?count=true" \
-H "x-api-key: $LEADOCEAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"jobLevel": ["VP"],
"jobFunction": ["Sales & Business Development"],
"country": ["US"],
"employeeRange": ["51-200"],
"limit": 1
}' | jq '.meta'count=true goes in the query string, not the body. Enum values are exact strings, so resolve them with leadocean_list_enum_values instead of guessing.
Step 4: Fetch the rows
Now pull ten people. The body is flat JSON, filters are arrays and limit runs from 1 to 100.
curl -s -X POST https://api.leadocean.io/v1/people/search \
-H "x-api-key: $LEADOCEAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"jobLevel": ["VP"],
"jobFunction": ["Sales & Business Development"],
"country": ["US"],
"employeeRange": ["51-200"],
"limit": 10
}' | jq '{count: (.data | length), next: .meta.nextCursor}'That spends 10 records. To page further, pass cursor from meta.nextCursor. One search pages to 10,000 rows at most, then meta.depthCapped is true.
Step 5: Enrich one record and decide
Enrichment takes exactly one of linkedin_url, email, phone or person_id. There is no name-plus-domain lookup, so the agent searches first and enriches by person_id.
curl -s -X POST https://api.leadocean.io/v1/people/enrich \
-H "x-api-key: $LEADOCEAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"person_id": "PERSON_ID_FROM_STEP_4", "reveal_email": true}'An enrichment that finds nobody returns a 404 and costs nothing. The response includes career history in resume_data. A good agent uses it: a VP who joined three months ago is a different message than one with six years in seat.
Step 6: Add the stop rule
This is the part tutorials skip. Without it, an agent retries until your records are gone.
Rules for the agent:
- Call leadocean_count_leads before any search. If the total is over 20,000, narrow the filters.
- Never fetch more than 10 people per run.
- Enrich at most 3 people per run.
- If a call returns 402 or 429, stop and report. Do not retry.Put these in the system prompt or a CLAUDE.md file. A hard cap in your own code is safer than a polite instruction.
What you get
Step 3 is the free sizing call. We ran it on 2026-10-21 through leadocean_count_leads. Filters: VP, Sales & Business Development, US, 51-200 employees. Result:
{
"total": 18567,
"totalIsExact": true,
"totalAll": 60456,
"distinctCompanies": 12192,
"credits": 0
}total is the mailable audience: people whose best email is verified, catch_all_valid or catch_all. totalAll is the same filters with no email condition. The call cost zero records.
Step 4 returns people in the shape below (response shape from the API reference, placeholder values only):
{
"success": true,
"data": [
{
"profile_data": { "profile_full_name": "Jane Doe", "profile_headline": "VP Sales at Acme" },
"contact_data": {
"has_email": true,
"email_status": "verified",
"contact_current_experiences": [
{ "job_title": "VP Sales", "company_name": "Acme", "company_domain": "acme.com" }
]
},
"meta": { "source_ids": { "person_id": "123456789" } }
}
],
"meta": { "nextCursor": "CURSOR" }
}The person_id for Step 5 is at meta.source_ids.person_id. Search rows carry email flags, not the address.
Troubleshooting
| Error | Cause | Fix |
|---|---|---|
| 401 | Missing or bad x-api-key header | Check $LEADOCEAN_API_KEY is exported in this shell |
| 429 | Above the plan's rate limit (5 requests a second on Free, 200 on Agency) | Honour Retry-After, or serialise the agent's calls |
| 402 | Records spent (1,000 on Free, for life) | Move to a paid plan, see pricing |
| Empty results | An enum value with the wrong case, such as vp for jobLevel | Resolve it with leadocean_list_enum_values; jobLevel takes VP, seniority takes vp |
| Count fails or returns 1,000 | A funding or revenue filter passed to the count tool | Count without it and add the filter at search time |
| Export refused | Over 50,000 rows a request or 500,000 a day | Split the export; bulk CSV is not on Free |
FAQ
What is an AI sales agent?
A program where a language model picks the next tool call, such as a data search or a CRM write. A rule tells it when to stop. It differs from a script because the model chooses the order of steps.
Is an AI sales agent the same as an AI SDR?
An AI SDR is one product shape: an agent aimed at outbound. The loop is the same. See AI SDR and custom sales agents and B2B sales agents.
What does the agent need from a data provider?
A free way to size a list, filters with exact enum values and per-record billing it can reason about. LeadOcean's count calls are free and search spends one record per person returned.
Can it run on a schedule?
Yes, but the agent has no scheduler of its own. Run it from cron or a workflow tool and keep the per-run caps. For a related pattern, read what a RevOps AI agent is.
How much does it cost to run?
The free plan covers 1,000 records for life. Paid plans are Solo at $97 a month and Agency at $497 a month, with a fair-use pace instead of credits. See pricing.
Give your sales agent a data source it can count before it spends
Free to start. No credit card. 1,000 records to spend whenever you like.
Get your free API key →