hubspot_search_deals
HubSpot read low risk
Part of the HubSpot Agent.
What it does
Search HubSpot deals by property filters, returning a paginated list of matching deals with requested properties. Same filter model as contact search: filterGroups are OR'd and the filters inside a group AND'd (HubSpot's search guide gives at most 5 groups, 6 filters per group and 18 in total; a search over its limit fails with HubSpot's 400 VALIDATION_ERROR); operators EQ/NEQ/LT/LTE/GT/GTE/BETWEEN/IN/NOT_IN/HAS_PROPERTY/NOT_HAS_PROPERTY/CONTAINS_TOKEN/NOT_CONTAINS_TOKEN; plus query, sorts, properties, limit (<=200), after. Returns the standard envelope {success:true,data} where data is {results, total, paging.next.after}. Use to find deals by pipeline/stage, find deals associated with a campaign attribution value, locate an existing deal before creating (dedupe), or list deals modified since the last sync cursor for closed-loop ROI. [POLICY] Search/surface ONLY the authorizing client's own deals for that client's consented purposes; never use deal search to assemble cross-client intelligence or prospecting.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
filterGroups | array | no | Groups are OR'd and the filters inside a group AND'd: {propertyName, operator, value|values|highValue} (HubSpot's search guide: at most 5 groups, 6 filters per group, 18 in total). E.g. filter dealstage IN [...] or pipeline EQ <id>. |
query | string | no | Free-text search across default searchable deal properties (e.g., dealname). |
properties | array | no | Property names to return (e.g., [dealname, amount, dealstage, pipeline, closedate, hs_object_id]). |
sorts | array | no | Sort spec, e.g. [{propertyName:"hs_lastmodifieddate", direction:"ASCENDING"}] for incremental sync cursoring. |
limit | integer | no | Page size, default 10, max 200. |
after | string | no | Paging cursor from a prior response's paging.next.after. |
Safeguards
Policy
Search/surface ONLY the authorizing client's own deals for that client's consented purposes. NEVER use deal search to assemble cross-client intelligence, prospecting lists, or to commingle data across unaffiliated accounts.
Reminder
Keep filters within HubSpot's documented search limits (5 filterGroups, 6 filters each, 18 in total); page via the after cursor with a stable sort.
Errors
| Error class | Means | What to do | Retry |
|---|---|---|---|
auth | Invalid or expired OAuth token / session (401 Unauthorized). | Refresh the HubSpot OAuth token and retry; do not reuse the rejected token. | no |
permission | Token lacks crm.objects.deals.read scope or portal denied access (403 Forbidden). | Grant crm.objects.deals.read and reconnect; surface the missing scope. | no |
validation | HubSpot 400: too many filterGroups/filters, unknown propertyName, or malformed operator/value. Surface HubSpot's exact message. | Correct the filters (HubSpot's guide: 5 groups, 6 per group, 18 in total) and property names, then retry. | no |
rate_limit | HubSpot 429 Too Many Requests. The Search API is capped at ~5 requests/second at the ACCOUNT level (shared across the portal), plus global secondly/daily limits. | Throttle to the account-level search limit, serialize concurrent searches, honor Retry-After/X-HubSpot-RateLimit-*, back off with jitter. | yes |
not_found | Endpoint/object type not found (404) -- wrong object path. | Verify the path is deals; correct and retry. | no |
platform | HubSpot server error (500/502/503). | Retry with exponential backoff; if persistent, report HubSpot unavailability. | yes |
Edge cases
- Empty results: {results:[], total:0} is valid, not an error (success:true, data.total 0).
- Pagination: follow paging.next.after; search caps reachable results at 10,000 per query -- use date-window filters for larger sets.
- Indexing lag: a just-created deal may not appear immediately in search -- prefer get-by-id for read-after-write dedupe.
- Incremental sync: filter hs_lastmodifieddate GT cursor and sort ASCENDING to avoid skips/dupes across pages.
- amount is returned as a string; parse to number for math.
- Keep filters within the client's scope -- never broaden to harvest other portals' or clients' deals.