Auth0 Home Blog Docs

User Search API - query limit



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


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 and restrict access to the link for only emails using


Hi Prashant. Thanks. Locked Gist to accounts created as suggested: gist
72 always works, 73 always fails.
Regards, Tim



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


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


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.


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


@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_ids fail if their length exceeds 72