Search CRM Objects
masterUse the searchApi.doSearch method to query objects with filters and sorting.
Constraints:
- Supports a maximum of 3
FilterGroups, each with a maximum of 3Filters. - Only one
sortparameter is supported at a time. - For the initial search,
aftershould be set to0.
Sorting in JavaScript:
propertyName: Sorts by property inASCENDINGorder (e.g.,'hs_object_id').{ propertyName, direction }: Explicit direction (e.g.,{ propertyName: 'hs_object_id', direction: 'DESCENDING' }).
Sorting in TypeScript:
['propertyName']: Sorts inASCENDINGorder.['-propertyName']: Sorts inDESCENDINGorder.
// JS Search Example
const publicObjectSearchRequest = {
filterGroups: [{
filters: [{
propertyName: 'createdate',
operator: 'GTE',
value: `${Date.now() - 30 * 60000}`
}]
}],
sorts: [{ propertyName: 'createdate', direction: 'DESCENDING' }],
properties: ['createdate', 'firstname', 'lastname'],
limit: 100,
after: 0,
};
const response = await hubspotClient.crm.contacts.searchApi.doSearch(publicObjectSearchRequest);