Find companies and/or prospects using any combination of filters.
**Session Storage:**
- If session_id is provided, results will be stored for future reference
- If not provided, a new session_id will be created and returned
- Returns session_id in the response for future data retrieval
**WHAT TO DO:**
- Set `entity_type`, `filters`, required `page_size` (max 500; recommend 50 when the user does not specify a count), and `next_cursor` (null for page one). Use `max_per_company` only for prospects when the user specifies a per-company limit; keep all of these stable when chaining `next_cursor` pages.
Each run uses **full** mode; cursor pagination is defined under **PAGINATION** below (aligned with `fetchPaginatedData`).
- Whenever the user is asking to find companies who need or are showing intent/interest/relevancy for a certain product or service, use the business_intent_topics filter.
- ALWAYS use autocomplete for the following filters: linkedin_category, naics_category, job_title, interests, skills, business_intent_topics, company_tech_stack_tech.
- **CRITICAL:** Standardized values from autocomplete MUST be used in the subsequent fetch call. DO NOT use raw user input for these filters under any circumstances.
- **PERSISTENCE:** Ensure standardized values are preserved and used even if other tools (like match) are called between autocomplete and fetch.
**ENTITY_TYPE SELECTION (REQUIRED):**
- **Use "prospects"** - When request involves people/individuals in ANY way
- **Use "businesses"** - When request is ONLY about companies with NO people
**KEY: Any people-related request = use "prospects" directly**
**LOCATION FILTERS:**
- `company_country_code` / `company_region_country_code` filter the company's HQ location.
- `prospect_country_code` / `prospect_region_country_code` filter where the person is based.
- If `entity_type` is `prospects` and the user mentions a location without making clear whether it applies to the person or the company, ask before fetching:
"Before I search, when you say "in <location>", do you mean:
- Prospects who are physically based there
- Prospects working at companies headquartered there
- Both: prospects who are physically based there and work at companies headquartered there"
- Do not ask when the wording is clear, such as "companies in Germany" (company HQ) or "prospects based in New York" (prospect location).
- Only call this tool after the user confirms which location filter to use.
**PROSPECT CONTACT INFO (EMAIL / PHONE):**
- Availability only, not contact values: "email" = email available; "phone" = phone available; "email_or_phone" = at least one; "email_and_phone" = both. Profile only: omit contact filters, including deprecated filters.
- Ask before prospect fetch unless the prompt/current dataset specifies a preference. Never ask for business-only searches. MUST show all four options verbatim, in order; never omit or merge "Email or phone (or Both)":
"Before I search, would you like to include contact details in your results?
- Emails only
- Phones only
- Email or phone (or Both)
- No, only prospect profile"
- Set `filters.has_contact_details.value`, in option order: `email`, `phone`, `email_or_phone`, or omit the filter. Email does not exclude prospects with phones.
- Apply explicit preferences directly (phone/mobile only → `phone`). Map clear free text/"Something else"; ask if ambiguous. Retain the preference until the dataset or preference changes.
- Profile only: no contact enrichment.
- For requested contacts, run `enrich-prospects` with `enrichments: ["contacts"]` and fetched `prospect_ids` in the same `session_id`; use enriched results downstream.
**EVENT DETAILS:**
- `filters.events` only selects businesses with that signal—it does not add event detail fields to fetch results.
- If the fetch used `filters.events` and the user did not already ask for event details in the same message, you MUST ask after presenting results and before `fetch-*-events`:
"Would you like me to retrieve event details for these results?
- Yes, get event details
- No thanks, keep results as-is"
- Wrong: call `fetch-*-events` immediately after `fetch-entities` returns results with matching event signals.
- Right: present the matching results, ask the event-details question, and call `fetch-*-events` only after the user confirms.
- If yes: run `fetch-*-events` with matching `event_types`.
**PAGINATION (cursor, matches `fetchPaginatedData`)**
Treat each HTTP body as the **same search** with only `next_cursor` advancing. The worker always sends `page_size: max(page_size, max_per_company || 0)`; keep that pair (and `filters`, `entity_type`) identical across the chain or you risk duplicates/gaps.
- **First call:** `entity_type`, `filters`, `page_size`; add `max_per_company` only for prospects if the user asked. `next_cursor` defaults to null (omit it or pass null); the POST body sends `next_cursor: null` like `fetchPaginatedData`.
- **Next token:** for prospect fetches, expect `page.next_cursor` in normal cases. Business fetches may return page metadata instead. Read `page.next_cursor` first, else top-level `next_cursor`; pass any returned cursor verbatim.
- **Continue:** same args as the first call; set `next_cursor` to the token. Do not add `max_per_company` later if the first call omitted it.
- **Stop:** no token, empty rows, or the user has enough. `total_results` is total matches; each response is at most one batch (`max(page_size, max_per_company || 0)` rows).
- **New search:** change filters, entity type, `page_size`, or `max_per_company` → drop `next_cursor` and start over.
**WORKFLOW:** `fetch-entities` (no cursor) → optional repeats with `next_cursor` → optional `enrich-business` / `enrich-prospects` **only if user asks or answers the contact-details prompt with email only, phone only, both, or either** → if `filters.events` was used: use the event-details prompt before `fetch-*-events`
**REQUEST PLANNING:** One complete filter set on the first call; do not parallelize the same intent across multiple first pages.
**PRESENTATION**
- Show **every row** returned in a complete "left-join style" markdown table with **all available fields** from the API.
- NEVER mention internal table names or technical internals.
**RESULT LIMITS**
- Each call returns up to one batch of size `max(page_size, max_per_company || 0)`. Load more by chaining `next_cursor` as above, not by shrinking or growing `page_size` mid-search.
**MAX_PER_COMPANY**
- **CRITICAL: USE ONLY IF USER SPECIFIES A NUMBER.**
**BUYING INTENT (CRITICAL FOR SALES PROSPECTING)**
- When user wants to find potential customers/prospects for what they're selling
- Use business_intent_topics filter (requires autocomplete)
- Example Keywords: "selling to", "need", "looking for", "interested in buying", "prospects for"
**JOB FILTER RULES**
- Broad role categories: use `job_level` + `job_department` ONLY (never `job_title`).
- Example: job_level ["c-suite", "director", "vice president"] + job_department ["engineering"]
- Specific titles: use `job_title` ONLY.
- `job_level`/`job_department` are more precise; if seniority/department is requested, ALWAYS use them.
- Use autocomplete to get standardized job titles.
- If too broad, narrow with `website_keywords`.
**AMBIGUOUS TERMS**
- For broad/ambiguous terms toggle options (e.g., "designers", "engineers", "security", "mining", "consulting"):
- Present specific subcategory options AND an option to search **ALL relevant categories (including the general term)**.
- **Do not auto-select** the general term without user choice.
**AUTOCOMPLETE REQUIREMENTS:**
These filters REQUIRE autocomplete before fetch-entities:
- linkedin_category
- naics_category
- job_title
- interests
- skills
- business_intent_topics
- company_tech_stack_tech
- city_region (only for USA cities)
**MANDATORY RULE:** If you use ANY of these filters, you MUST call autocomplete FIRST.
NO EXCEPTIONS. NO SHORTCUTS.
Once you have the autocomplete results, you MUST use them in the fetch-entities call. DO NOT revert to the user's original raw input. Standardized values MUST persist even if multiple tools are used in sequence.
**Exception:** If autocomplete returns empty results after broadening your query once, skip that filter entirely.
**EVENT-BASED FILTERS (use enum values directly, no autocomplete needed):**
- `events`: Object with "values" (array of event types from fixed enum) and "last_occurrence" (days: 30-90)
**Do NOT autocomplete these filters (use directly):**
- country_code, company_country_code → use ISO Alpha-2 codes (e.g., "US", "IL")
- region_country_code, company_region_country_code → use ISO 3166-2 codes (e.g., "US-CA", "IL-TA")
- business_id, prospect_id → extract from previous results
**CONSTRAINTS**
- For enum-backed filters, use schema enum values directly.
- Never set more than one of: `linkedin_category`, `naics_category`.
- Never set both `region_country_code` and `country_code`; same for company.
- Run enrich tools only if user asks or answers the contact-details prompt with email only, phone only, both, or either.
- To filter by a specific company, first call match-business to get its ID, then pass it here.
- Returns Business/Prospect IDs; do NOT chain with `match-business` / `match-businesses` / `match-prospects`.
- If a filter is unsupported/invalid, stop and alert the user.