Query field in v3 search API

I am trying to use the v3 search API (/crm/v3/objects/contacts/search). I’ve been struggling to understand the

query

field… I haven’t been able to find any documentation on it, or examples. It seems the combination of the

properties

and

filterGroups

fields in the request specifiy what records you want, and what properties you want to retrieve, so what is the purpose of the

query

field? And can anyone point me at an example of how to use it?

I’m new to HubSpot and decided to dive directly into the v3 API; maybe this is a concept carried over from earlier versions of the API?

Hey @nstansby,

Welcome to HubSpot :slightly_smiling_face:

The query will search based on the default searchable properties (mentioned on this documentation: CRM API | Search) i.e. for contacts, it would be firstname, hs_additional_emails, phone, hs_object_id, hs_searchable_calculated_phone_number, company, email and lastname.

Thanks @WendyGoh , I’d just been looking at the endpoint documentation. The link you sent is exactly what I needed.

Hi @WendyGoh ,

I have a similar use case where i want to filter by the lastmodifieddate property to get the tickets records since the last timestamp. Is it possible to get this data from the search crm api?

Man, this document is crazy. That thing should be documented in below section instead of letting developers struggle to search for answer in Google.

Hey @kawyns1,

This is possible via the HubSpot CRM API | Search. You can do something like this:

curl https://api.hubapi.com/crm/v3/objects/contacts/search?hapikey=YOUR_HUBSPOT_API_KEY \
 --request POST \
 --header "Content-Type: application/json" \
 --data '{
 "filterGroups":[
 {
 "filters":[
 {
 "propertyName": "lastmodifieddate",
 "operator": "EQ",
 "value": "{{timestamp here}}"
 }
 ]
 }
 ]
 }

Can anyone give some examples for the PHP in curl ?

Hi @WendyGoh

Is this API available via URL in the browser? Can you please give me an example of URL rather than curl?

For example, with API version 1, in order to list all contacts with specific properties I can paste in the browser with the following URL.

https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=YOUR_HUBSPOT_API_KEY&count=15&&propertyMode=value_and_history&property=YOURPROPERTIES

This is the correct answer and contains the important structure of the neccessary query object. Thank you.