# Filter list of contacts using php api

**URL:** https://forum.mautic.org/t/filter-list-of-contacts-using-php-api/27090
**Category:** Product Support
**Tags:** mautic-4
**Created:** [February 19, 2023, 6:11pm UTC](https://forum.mautic.org/t/filter-list-of-contacts-using-php-api/27090 "2023-02-19T18:11:12Z")
**Posts on this page:** 2
**Page:** 1

<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:11pm UTC](https://forum.mautic.org/t/filter-list-of-contacts-using-php-api/27090/1 "2023-02-19T18:11:12Z")

</div>

**Your software**  
My Mautic version is:v4.4.5  
My PHP version is:7.4.32  
My Database type and version is:5.7.40

**Your problem**  
My problem is: I would like to filter contacts belonging to a certain segment and then to send a custom email depending on user last activity.  
if I write like this

```auto
$response = $contactApi->getList('segment:newsletter', 0, 25);

```

I get a list (however besides of correct email addresses) I get also a list of contacts with empty emails

`Array ( [id] => 6 [label] => Email [alias] => email [type] => email [group] => core [object] => lead [is_fixed] => 1 [properties] => a:0:{} [default_value] => [value] => [normalizedValue] => )`

So I have tried to build a composed where clause from array of arrays like in documentattion  
[https://developer.mautic.org/#list-contacts](https://developer.mautic.org/#list-contacts)

and any attempt to set a filter like

`$where = [['col' => 'segment', 'expr' => 'eq','val' => 'newsletter']] ; $response = $contactApi->getList($where, 0, 25);`

fails. I have tried instead of “eq” expression to put “like” or “in” operator.  
It seems that it’s not taking care of what ever I put in the $where array.

Not to mention that other filters like  
$where = [[‘col’ =\> ‘segment’, ‘expr’ =\> ‘eq’,‘val’ =\> ‘newsletter’], [‘col’ =\> ‘email’, ‘expr’ =\> ‘isNotEmpty’]] ;

are not working either.

thank you,  
Daniel

---

<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 21, 2023, 3:41am UTC](https://forum.mautic.org/t/filter-list-of-contacts-using-php-api/27090/2 "2023-02-21T03:41:56Z")

</div>

no one ? what I am doing wrong on the filtering ?
