# Filtering contacts in API calls

**URL:** https://forum.mautic.org/t/filtering-contacts-in-api-calls/22550
**Category:** Product Support
**Created:** [January 31, 2022, 9:47pm UTC](https://forum.mautic.org/t/filtering-contacts-in-api-calls/22550 "2022-01-31T21:47:25Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![IMACS-Iain](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imacs-iain/32/6223_2.png) [@IMACS-Iain](https://forum.mautic.org/u/IMACS-Iain)
#### Post date: [January 31, 2022, 9:47pm UTC](https://forum.mautic.org/t/filtering-contacts-in-api-calls/22550/1 "2022-01-31T21:47:26Z")

</div>

Using the API call “GET /contacts/activity”

[https://developer.mautic.org/#get-activity-events-for-all-contacts](https://developer.mautic.org/#get-activity-events-for-all-contacts)

To filter the result for specified contacts it seems like the call should be

get /contacts/activity?search=ids:3,4,5,6

But this doesn’t work. I also tried

get /contacts/activity?filter=ids:3,4,5,6  
get /contacts/activity?ids=3,4,5,6

Can you suggest a solution?

Thank you. Iain.

---

<div class="post-metadata">

### Author: ![IMACS-Iain](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imacs-iain/32/6223_2.png) [@IMACS-Iain](https://forum.mautic.org/u/IMACS-Iain)
#### Post date: [February 2, 2022, 4:26pm UTC](https://forum.mautic.org/t/filtering-contacts-in-api-calls/22550/2 "2022-02-02T16:26:22Z")

</div>

More attempts:

get /contacts/activity?search=ids:1%2C2%2C3 (ids:1,2,3)  
get /contacts/activity?search=ids%3A1%2C2%2C3 (ids:1,2,3)  
get /contacts/activity?search=ids%3D1%2C2%2C3 (ids=1,2,3)  
…

---

<div class="post-metadata">

### Author: ![IMACS-Iain](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imacs-iain/32/6223_2.png) [@IMACS-Iain](https://forum.mautic.org/u/IMACS-Iain)
#### Post date: [February 9, 2022, 5:10pm UTC](https://forum.mautic.org/t/filtering-contacts-in-api-calls/22550/3 "2022-02-09T17:10:17Z")

</div>

Here are some more attempts (urlEncode does what you think it does):

“/api/contacts/activity” +  
“?where” +urlEncode( “[0][col]” ) + “=id” +  
&where" + urlEncode( “[0][expr]” ) + “=in” +  
“&where” + urlEncode( “[0][val]” ) + “=3,4,161435”  
“/api/contacts/activity” +  
“?where” +urlEncode( “[0][col]” ) + “=ids” +  
&where" + urlEncode( “[0][expr]” ) + “=in” +  
“&where” + urlEncode( “[0][val]” ) + “=3,4,161435”  
“/api/contacts/activity?ids:3,161435”  
“/api/contacts/activity?search=” + urlEncode(“ids:3,161435”)

Still no luck. Giving up.

---

<div class="post-metadata">

### Author: ![robm](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/robm/32/260_2.png) [@robm](https://forum.mautic.org/u/robm)
#### Post date: [February 10, 2022, 3:49am UTC](https://forum.mautic.org/t/filtering-contacts-in-api-calls/22550/4 "2022-02-10T03:49:56Z")

</div>

In case you have not seen this. I am successfully searching by API using these syntaxes.

> **[Search](https://docs.mautic.org/en/mautic-search)**
>
> . Search operators and filters. Mautic allows you to use a range of search operators and filters to drill down into relevant resources. The available search filters and operators can be found next to the search input by clicking on the button with...

---

<div class="post-metadata">

### Author: ![IMACS-Iain](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imacs-iain/32/6223_2.png) [@IMACS-Iain](https://forum.mautic.org/u/IMACS-Iain)
#### Post date: [February 10, 2022, 1:46pm UTC](https://forum.mautic.org/t/filtering-contacts-in-api-calls/22550/5 "2022-02-10T13:46:51Z")

</div>

Your reply is much appreciated. It can get lonely in here. Thank you.

I used that page a few days ago to construct a successful URL for a search of contacts like this:

“/api/contacts” +  
“?where” + IUtils.urlEncode( “[0][col]” ) + “=lastActive” +  
“&where” + IUtils.urlEncode( “[0][expr]” ) + “=gt” +  
“&where” + IUtils.urlEncode( “[0][val]” ) + “=” + fromtimestamp

But this form of URL doesn’t appear to work with /api/contacts/activity.

It says to use “filters[search]” with this endpoint … anyone know what that implies for the URL?
