# Filtering leads in 'list leads' API request

**URL:** <https://forum.mautic.org/t/filtering-leads-in-list-leads-api-request/3601>\
**Category:** Development\
**Created:** [April 26, 2016, 12:47pm UTC](https://forum.mautic.org/t/filtering-leads-in-list-leads-api-request/3601 "2016-04-26T12:47:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![seeeking](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@seeeking](https://forum.mautic.org/u/seeeking)\
**Post date:** [April 26, 2016, 12:47pm UTC](https://forum.mautic.org/t/filtering-leads-in-list-leads-api-request/3601/1 "2016-04-26T12:47:16Z")

</div>

Hi everybody  
  
  
  
I’m using API to manage leads through own PHP classes (due to our framework’s architecture ) and I’m trying to filter leads by the ‘search’ parameter in list leads request. **NB: I need to filter them by a custom field**.  
  
  
  
The API manual [states](https://developer.mautic.org/?php#list-leads) that it’s a “_String or search command to filter entities by_.”  
  
  
  
~~I’ve tried SQL instructions, key:value, key=value and all kinds of quotes’ combinations with these - nothing seems to impress the API: if the ‘search’ parameter isn’t empty, it always returns an empty array and count=0.  
  
~~  
  
  
  
Ok, I got the point: it works exactly like the search bar in the frontend (the ‘key:value’ commands work for name, email and some other standard fields).  
  
  
  
~~Now, **can I filter by multiple fields**?~~  
  
~~Say, I have two custom fields **client\_id** and **client\_status** and I need to retrieve records with client\_id=x **and** client\_status=y, is there a way to do it?~~  
  
  
  
**UPD** : Got it also figured out.  
  
  
  
The working format seems to be “ **field\_name1** :substring1 **field\_name2** :substring2” with a space between the key:value pairs.  
  
  
  
Now, the (hopefully) last question:  
  
Is there a way to search for **exact** field value, not substring?  
  
  
  
Thanks in advance ![:)]( ":)")

---

<div class="post-metadata">

**Author:** ![seeeking](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@seeeking](https://forum.mautic.org/u/seeeking)\
**Post date:** [April 26, 2016, 12:47pm UTC](https://forum.mautic.org/t/filtering-leads-in-list-leads-api-request/3601/2 "2016-04-26T12:47:16Z")

</div>

Hi everybody

I’m using API to manage leads through own PHP classes (due to our framework’s architecture ) and I’m trying to filter leads by the ‘search’ parameter in list leads request. NB: I need to filter them by a custom field.

The API manual [states](https://developer.mautic.org/?php#list-leads) that it’s a “String or search command to filter entities by.”

I’ve tried SQL instructions, key:value, key=value and all kinds of quotes’ combinations with these - nothing seems to impress the API: if the ‘search’ parameter isn’t empty, it always returns an empty array and count=0.

Ok, I got the point: it works exactly like the search bar in the frontend (the ‘key:value’ commands work for name, email and some other standard fields).

Now, can I filter by multiple fields?  
Say, I have two custom fields client\_id and client\_status and I need to retrieve records with client\_id=x and client\_status=y, is there a way to do it?

UPD: Got it also figured out.

The working format seems to be “field\_name1:substring1 field\_name2:substring2” with a space between the key:value pairs.

Now, the (hopefully) last question:  
Is there a way to search for exact field value, not substring?

Thanks in advance 🙂

---

<div class="post-metadata">

**Author:** ![dandumit](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dandumit/32/6497_2.png) [@dandumit](https://forum.mautic.org/u/dandumit)\
**Post date:** [February 19, 2023, 6:21pm UTC](https://forum.mautic.org/t/filtering-leads-in-list-leads-api-request/3601/3 "2023-02-19T18:21:13Z")

</div>

> [@seeeking](#):
>
> tly like the sea

hello @seeeking  
I am following the same path as you did in the past.  
and I am getting same results. it seems that it’s a bug or never been implemented.  
please tell me you have never managed to put multiple filters like array like col key value ?

Daniel
