# CRM API Search Filter

**URL:** <https://community.hubspot.com/t/crm-api-search-filter/78862>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [April 6, 2023, 3:42pm UTC](https://community.hubspot.com/t/crm-api-search-filter/78862 "2023-04-06T15:42:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![CS4](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@CS4](https://community.hubspot.com/u/CS4)\
**Post date:** [April 6, 2023, 3:42pm UTC](https://community.hubspot.com/t/crm-api-search-filter/78862/1 "2023-04-06T15:42:07Z")

</div>

The documentation for filters is confusing. I am trying to create the following scenario **‘(A or B) and c’**, where **‘or’** takes precendence over **‘and’**. Please let me know how to handle this kind of scenario using filter and filtergroups?

---

<div class="post-metadata">

**Author:** ![skimura](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@skimura](https://community.hubspot.com/u/skimura)\
**Post date:** [April 7, 2023, 9:14am UTC](https://community.hubspot.com/t/crm-api-search-filter/78862/2 "2023-04-07T09:14:16Z")

</div>

@CS4

Hi.

> * * *
> 
> * * *

> **[Search the CRM - HubSpot docs](https://developers.hubspot.com/docs/api-reference/latest/crm/search-the-crm)**
>
> The CRM search endpoints make getting data more efficient by allowing developers to filter, sort, and search across any CRM object type.

- To apply _AND_ logic, include a comma separated list of conditions within one set of `filters`.
- To apply _OR_ logic, include multiple `filters` with a `filterGroup`.

How about `(A and C) or (B and C)`?

```lia-code-sample
"filterGroups": [
 {
 "filters":[A],
 "filters":[C]
 },
 {
 "filters":[B],
 "filters":[C]
 },
]

```

Thanks.

---

<div class="post-metadata">

**Author:** ![CS4](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@CS4](https://community.hubspot.com/u/CS4)\
**Post date:** [April 8, 2023, 1:41pm UTC](https://community.hubspot.com/t/crm-api-search-filter/78862/3 "2023-04-08T13:41:48Z")

</div>

Hi skimura,

Thank you for the response. But I am still trying to figure out how to apply for the scenario **(A or B) and C**?

```lia-code-sample
"filterGroups": [
 {
 "filters":[A]
 },
 {
 "filters":[B]
 },
]

```

This will give **(A or B).** How shall I apply **and** operation for **(A or B)**.

---

<div class="post-metadata">

**Author:** ![skimura](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@skimura](https://community.hubspot.com/u/skimura)\
**Post date:** [April 8, 2023, 2:08pm UTC](https://community.hubspot.com/t/crm-api-search-filter/78862/4 "2023-04-08T14:08:00Z")

</div>

@CS4

I don’t think you can do it in this order because filter group cannot included in filter.

(same order: meens ‘**(A or B) and C**’)

But are’t ‘**(A or B) and C**’ and ‘**(A and C) or (B and C)**’ the same?

---

<div class="post-metadata">

**Author:** ![CS4](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@CS4](https://community.hubspot.com/u/CS4)\
**Post date:** [April 10, 2023, 4:19am UTC](https://community.hubspot.com/t/crm-api-search-filter/78862/5 "2023-04-10T04:19:22Z")

</div>

Thank you @skimura . I somehow missed your first response of expanding the condition which is same as what I was asking. I got the it clarified.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [April 10, 2023, 7:26pm UTC](https://community.hubspot.com/t/crm-api-search-filter/78862/6 "2023-04-10T19:26:54Z")

</div>

Hey, @CS4 👋 Thanks for letting us know you got it worked out 🙌 — Jaycee
