# User Search API - query limit

**URL:** <https://community.auth0.com/t/user-search-api-query-limit/7488>\
**Category:** Get Help\
**Tags:** api, users, search\
**Created:** [July 13, 2017, 1:38am UTC](https://community.auth0.com/t/user-search-api-query-limit/7488 "2017-07-13T01:38:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![twrcarter](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@twrcarter](https://community.auth0.com/u/twrcarter)\
**Post date:** [July 13, 2017, 1:38am UTC](https://community.auth0.com/t/user-search-api-query-limit/7488/1 "2017-07-13T01:38:29Z")

</div>

Hi - I’m issuing a call like this:

/api/v2/users?per\_page=100&q=user\_id%3A%22auth0%7C5718b1fffc0e6bec78f19999%22+OR+user\_id%3A%22auth0%7C571a10b376846f614c099999%22+OR+user\_id%3A%22auth0%7C571a1072345eb3401cf49999%22+OR+user\_id%3A%22auth0%7C5721d197d4e7160318329999 etc

When there are 72 terms, the query works. When 73 terms, the query fails {“statusCode”:503,“error”:“Service Unavailable”,“message”:“Failed to perform search.”}

I presume I’ve hit query limit, but I couldn’t see a limit on the length of the query described. Any ideas or thoughts would be welcome

Regards, Tim

---

<div class="post-metadata">

**Author:** ![prashantT](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/prashantt/32/6002_2.png) [@prashantT](https://community.auth0.com/u/prashantT)\
**Post date:** [July 13, 2017, 10:05am UTC](https://community.auth0.com/t/user-search-api-query-limit/7488/2 "2017-07-13T10:05:23Z")

</div>

I am not aware of a hard restriction on the number of search terms you can pass to the User Search API. Can you confirm that this behaviour occurs consistently when using 73 and 72 (i.e 72 always works, 73 always fails). If possible please also share the final request URL (it may be an issue with the length of the URL). Feel free to post it in a [Gist](https://gist.github.com/) and restrict access to the link for only `@auth0.com` emails using [Sharelock.io](http://Sharelock.io).

---

<div class="post-metadata">

**Author:** ![twrcarter](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@twrcarter](https://community.auth0.com/u/twrcarter)\
**Post date:** [July 13, 2017, 4:24pm UTC](https://community.auth0.com/t/user-search-api-query-limit/7488/3 "2017-07-13T16:24:44Z")

</div>

Hi Prashant. Thanks. Locked Gist to @auth0.com accounts created as suggested: [gist](https://sharelock.io/1/3sni-Hg4C0186jRxag884YAH4srL_eQL5DOz2fC76iU.izuYfX/40OPIhe2CPhHps-VrBJcCVj6Vu7ccGgR5nFrW8wesDv1Pp1vJq/TPznZhai9foZmspnm-QhYaMupKvXODnjV9wrTEYoce0JCPps2V/11Dh_334rLyKySqceX4vPKgRbwIkqUXmJsQw.NdSokBbahpy4O/z8AhXNhig)  
72 always works, 73 always fails.  
Regards, Tim

---

<div class="post-metadata">

**Author:** ![twrcarter](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@twrcarter](https://community.auth0.com/u/twrcarter)\
**Post date:** [July 13, 2017, 4:26pm UTC](https://community.auth0.com/t/user-search-api-query-limit/7488/4 "2017-07-13T16:26:02Z")

</div>

[https://sharelock.io/1/3sni-Hg4C0186jRxag884YAH4srL\_eQL5DOz2fC76iU.izuYfX/40OPIhe2CPhHps-VrBJcCVj6Vu7ccGgR5nFrW8wesDv1Pp1vJq/TPznZhai9foZmspnm-QhYaMupKvXODnjV9wrTEYoce0JCPps2V/11Dh\_334rLyKySqceX4vPKgRbwIkqUXmJsQw.NdSokBbahpy4O/z8AhXNhig](https://sharelock.io/1/3sni-Hg4C0186jRxag884YAH4srL_eQL5DOz2fC76iU.izuYfX/40OPIhe2CPhHps-VrBJcCVj6Vu7ccGgR5nFrW8wesDv1Pp1vJq/TPznZhai9foZmspnm-QhYaMupKvXODnjV9wrTEYoce0JCPps2V/11Dh_334rLyKySqceX4vPKgRbwIkqUXmJsQw.NdSokBbahpy4O/z8AhXNhig)

---

<div class="post-metadata">

**Author:** ![prashantT](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/prashantt/32/6002_2.png) [@prashantT](https://community.auth0.com/u/prashantT)\
**Post date:** [July 20, 2017, 9:29am UTC](https://community.auth0.com/t/user-search-api-query-limit/7488/5 "2017-07-20T09:29:23Z")

</div>

@twrcarter I am attempting to reproduce this on my. Could you also describe the use case you’re trying to achieve. Specifically, I’m interested in knowing why you’d need to search for so many users in a single search?

---

<div class="post-metadata">

**Author:** ![twrcarter](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@twrcarter](https://community.auth0.com/u/twrcarter)\
**Post date:** [July 20, 2017, 2:11pm UTC](https://community.auth0.com/t/user-search-api-query-limit/7488/6 "2017-07-20T14:11:19Z")

</div>

Hi Prashant - re the use case. We provide services to Organizations. Each Organization can have many Users. We store each User’s details in auth0. The use case is to provide a list of all the user’s details associated with an organization. Regards, Tim

---

<div class="post-metadata">

**Author:** ![prashantT](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/prashantt/32/6002_2.png) [@prashantT](https://community.auth0.com/u/prashantT)\
**Post date:** [July 21, 2017, 8:29am UTC](https://community.auth0.com/t/user-search-api-query-limit/7488/7 "2017-07-21T08:29:32Z")

</div>

Have you considered storing Organization information in `app_metadata` of the user profile, which will allow you to do a much simpler search.

E.g. app\_metadata structure of user:

```
app_metadata: {
    "organization": "ABC"
}

```

Then a search can be performed with the query: `app_metadata.organization: "ABC"`. This will return all users that have `organization: "ABC"` in the app\_metadata.

---

<div class="post-metadata">

**Author:** ![twrcarter](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@twrcarter](https://community.auth0.com/u/twrcarter)\
**Post date:** [July 21, 2017, 2:48pm UTC](https://community.auth0.com/t/user-search-api-query-limit/7488/8 "2017-07-21T14:48:50Z")

</div>

Hi Prashant - that’s an elegant solution and is one I will bear in mind for a possible refactoring. I’d still be interested to know what limit we’ve hit though, so that I can make sure our code conforms to said limits. Regards, Tim

---

<div class="post-metadata">

**Author:** ![vojtechstepancik](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vojtechstepancik/32/7394_2.png) [@vojtechstepancik](https://community.auth0.com/u/vojtechstepancik)\
**Post date:** [October 27, 2017, 8:35pm UTC](https://community.auth0.com/t/user-search-api-query-limit/7488/9 "2017-10-27T20:35:31Z")

</div>

@prashant You suggested using `app_metadata` as a way to simplify user querying without the need for an external database. However, as the ability to search `app_metadata` is gone, shouldn’t this limit be documented somewhere? I can confirm that queries with a chain of `user_id`s fail if their length exceeds 72

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:55am UTC](https://community.auth0.com/t/user-search-api-query-limit/7488/10 "2018-03-02T05:55:20Z")

</div>


