# Using the Search api

**URL:** <https://community.hubspot.com/t/using-the-search-api/47988>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [December 3, 2021, 7:37pm UTC](https://community.hubspot.com/t/using-the-search-api/47988 "2021-12-03T19:37:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HNunez](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@HNunez](https://community.hubspot.com/u/HNunez)\
**Post date:** [December 3, 2021, 7:37pm UTC](https://community.hubspot.com/t/using-the-search-api/47988/1 "2021-12-03T19:37:55Z")

</div>

Hi there! I was wondering if there is anyone out there that can help me using the Search api. When I use the the filterGroups parameter I get an error with the “operator” params. I have tried all the avaliable options for its value and even I tried setting it at null and still I get errors. Can someone help me please??

const PublicObjectSearchRequest = { filterGroups: [{“filters”:[{“value”:“string”,“propertyName”:“string”,“operator”:“EQ”}]}], sorts: [“string”], query: “string”, properties: [“string”], limit: 0, after: 0 };

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [December 6, 2021, 7:35am UTC](https://community.hubspot.com/t/using-the-search-api/47988/2 "2021-12-06T07:35:33Z")

</div>

Hi @HNunez ,  
I tested the code below and it should work:

```lia-code-sample
const hubspot = require('@hubspot/api-client');

const hubspotClient = new hubspot.Client({"apiKey":"YOUR_HUBSPOT_API_KEY"});

const PublicObjectSearchRequest = { filterGroups: [{"filters":[{"value":"Teun","propertyName":"firstname","operator":"EQ"}]}], sorts: ["firstname"], properties: [["firstname","lastname"]], limit: 0, after: 0 };

try {
 const apiResponse = await hubspotClient.crm.contacts.searchApi.doSearch(PublicObjectSearchRequest);
 console.log(JSON.stringify(apiResponse.body, null, 2));
} catch (e) {
 e.message === 'HTTP request failed'
 ? console.error(JSON.stringify(e.response, null, 2))
 : console.error(e)
}

```

Did you fill in all the required params?

---

<div class="post-metadata">

**Author:** ![RVu](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@RVu](https://community.hubspot.com/u/RVu)\
**Post date:** [June 5, 2022, 4:53am UTC](https://community.hubspot.com/t/using-the-search-api/47988/3 "2022-06-05T04:53:40Z")

</div>

Does this work for custom properties added to a contact?  
For example:

`{ filterGroups: [{"filters":[{"value": "X3vsi8", "propertyName":"app_user_id", "operator": "EQ"}] }`

Does this search api cover custom fields? And what if our custom field is required - does this change anything?

---

<div class="post-metadata">

**Author:** ![HNunez](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@HNunez](https://community.hubspot.com/u/HNunez)\
**Post date:** [December 7, 2021, 5:42pm UTC](https://community.hubspot.com/t/using-the-search-api/47988/4 "2021-12-07T17:42:03Z")

</div>

Thank You!!! @Teun
