Answered

Search for Contacts using the `IN` operator

  • 2 March 2021
  • 9 replies
  • 295 views

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!

icon

Best answer by Roy 15 October 2021, 22:22

View original

9 replies

Userlevel 1

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.

Thanks Eric, really appreciate!

@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.

Userlevel 1
Badge

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

{
"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?

@eric f11​ - Any movement at all?

Userlevel 1

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

Userlevel 1
Badge

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.

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...

Reply