hubspot_search_contacts
HubSpot read low risk
Part of the HubSpot Agent.
What it does
Search HubSpot contacts by property filters, returning a paginated list of matching contacts with requested properties. Supports filterGroups (OR across groups, AND within a group) of {propertyName, operator, value} where operator is one of EQ, NEQ, LT, LTE, GT, GTE, BETWEEN, IN, NOT_IN, HAS_PROPERTY, NOT_HAS_PROPERTY, CONTAINS_TOKEN, NOT_CONTAINS_TOKEN; plus a free-text query, sorts, properties to return, limit (page size, max 200), and after (paging cursor). Returns the standard envelope {success:true,data} where data is {results:[...], total, paging.next.after}. Use to find a contact by email before associating, to list contacts changed since the last nightly sync (lastmodifieddate GT cursor), or to locate a client's leads by hs_lead_status or lifecyclestage. Name properties by their HubSpot internal names: standard ones such as email, firstname, lastname, company, jobtitle, phone, lifecyclestage, hs_lead_status, createdate, lastmodifieddate; any other property must already exist in the portal and be named by its internal name. [POLICY] Search and surface ONLY the authorizing client's own contacts for that client's consented purposes; never use search to assemble a prospecting list, enrich third-party profiles, or pull data across client boundaries. HubSpot's search guide gives at most 5 filterGroups, 6 filters per group and 18 filters in total; Scalix passes filterGroups through unchanged, and a search over HubSpot's limit fails with its 400 VALIDATION_ERROR.
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 gives at most 5 groups, 6 filters per group and 18 filters in total; a search over its limit fails with HubSpot's 400 VALIDATION_ERROR. |
query | string | no | Free-text search across default searchable contact properties. |
properties | array | no | Property names to return per result (defaults: createdate, email, firstname, lastname, hs_object_id, lastmodifieddate). |
sorts | array | no | Sort spec, e.g. [{propertyName:"lastmodifieddate", direction:"ASCENDING"}]. Used as the stable cursor for incremental sync. |
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 contacts for that client's consented purposes. NEVER use search to build a prospecting list, enrich/append/verify third-party profiles, or pull data across client boundaries or unaffiliated accounts.
Reminder
Keep filters within HubSpot's documented search limits (5 filterGroups, 6 filters each, 18 in total); page with the after cursor and a stable sort -- never rely on offset.
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.contacts.read scope or portal denied access (403 Forbidden). | Grant crm.objects.contacts.read and reconnect; surface the missing scope. | no |
validation | HubSpot 400: more filterGroups/filters than HubSpot's search accepts (its guide: 5 groups, 6 per group, 18 in total), unknown propertyName, or malformed operator/value. Surface HubSpot's exact message. | Reduce/correct filters and operators per the limits, 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 all users/tokens of that portal), in addition to the global secondly/daily caps. | 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) -- typically a wrong object path. | Verify the object type path is contacts; 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 a valid non-error response (success:true, data.total 0).
- Pagination: follow paging.next.after until absent; search caps reachable results at 10,000 total per query -- narrow with createdate/lastmodifieddate windows for larger sets.
- Eventual consistency: very recently written/updated contacts may not yet appear in the search index (indexing lag) -- prefer get-by-id for read-after-write.
- Incremental sync: filter lastmodifieddate GT last_cursor and sort ASCENDING to avoid skips/duplicates across pages.
- Search rate limit (~5/sec account-level) is tighter than CRM object reads -- serialize and throttle.
- Never widen filters to harvest non-client data; results must stay within the authorizing client's records.