Skip to main content
Answered

Search for Contacts using the `IN` operator


I'm trying to search my Contacts by their `id` using the `IN` operator that is listed in API v2.3 reference (https://developers.intercom.com/intercom-api-reference/reference#section-accepted-operators

This is my current request payload:

```json

{

"query": {

"operator": "OR",

"value": [

{

"field": "id",

"operator": "IN",

"value": ["5fec4b003ba34a1198516369","5fec4b003ba34a11ab516481"]

}

]

}

}

```

 

but I get back an invalid response

```json

{

"type": "error.list",

"request_id": "000bcmd8o18tsjg9qfq0",

"errors": [

{

"code": "invalid_field",

"message": "_id is not a valid search field"

}

]

}

```

It looks like that this field can't be used to search with the IN operator (this request works if I use `email` field, for example) despite what is written in the "Accepted Fields" chapter (https://developers.intercom.com/intercom-api-reference/reference#section-accepted-fields

 

If I try to search by ID with other operators (like a long list of OR conditions) it works.

```json

{

"query": {

"operator": "OR",

"value": [

{

"field": "id",

"operator": "=",

"value": "5fec4b003ba34a1198516369"

},

{

"field": "id",

"operator": "=",

"value": "5fec4b003ba34a11ab516481"

},

[...]

```

 

Also the limitation

> There’s a limit of max 15 filters for each AND or OR group

means that, even with the IN operator, we cannot search for more than 15 users (emails) at a time?

 

Thanks!

Best answer by Roy

Hello @dan a11​ ,

 

Upon checking you are right it's not possible to use the "external_id" parameter to search users.

 

You can store Interom id's in your database and retrieve contacts via Intercom IDs - Just use retrieve contact API.

View original
Did this topic help you find an answer to your question?

9 replies

Eric Fitz
Employee
Forum|alt.badge.img+5
  • Employee
  • 1630 replies
  • March 4, 2021

Hey @rubens​, this is a known issue on our end. I've added your report to the bug report on our end, and I'll let you know once it's resolved.


  • Author
  • New Participant
  • 1 reply
  • March 4, 2021

Thanks Eric, really appreciate!


  • New Participant
  • 4 replies
  • August 11, 2021

@eric f11​ Is there any movement on this? I've discovered the same problem but with "external_id", which returns a "user_id is not a valid search field" error message.


Forum|alt.badge.img+5
  • Expert User
  • 1152 replies
  • August 11, 2021

Hi @dan a11​ 👋, Can you post a request? I will be happy to take a look 😇


  • New Participant
  • 4 replies
  • August 12, 2021
{
"query": {
"operator": "OR",
"value": [{
"field": "external_id",
"operator": "IN",
"value": ["someIdValueHere","anotherIdValueHere"]
}]
}
}

Thanks, @roy s11​ .

I think it's almost exactly the same as OP's - except referring to "external_id" instead of "id".

Error message is "user_id is not a valid search field" - which I assume is a hangover from when that field was called user_id?


  • New Participant
  • 4 replies
  • October 5, 2021

@eric f11​ - Any movement at all?


Eric Fitz
Employee
Forum|alt.badge.img+5
  • Employee
  • 1630 replies
  • October 15, 2021

Hey @roy s11​, I know you're very busy, but did you ever get a chance to look at @dan a11​'s sample request?


Forum|alt.badge.img+5
  • Expert User
  • 1152 replies
  • Answer
  • October 15, 2021

Hello @dan a11​ ,

 

Upon checking you are right it's not possible to use the "external_id" parameter to search users.

 

You can store Interom id's in your database and retrieve contacts via Intercom IDs - Just use retrieve contact API.


  • New Participant
  • 4 replies
  • October 18, 2021

Just to confirm - based on OP's post (searching by Intercom ID) and my subsequent query (searching by external_id), there's no way to search for contacts using the IN syntax with either their Intercom ID or an external ID at all?

 

Changing my database schema, migrating Intercom data into that new column, and then making separate calls per contact to the "retrieve contact" API seems a little heavy handed to do something that seems like it should just work...


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings