Auth0 allows you, as an administrator, to search for users using Lucene Query Syntax.
This document provides sample queries and demonstrates how you can search for users. We also suggest that you refer to Query String Syntax for more examples of query string syntax.
Search for users using the Management API
You can also search for users using the Management API. Two of the easiest ways to do this is by either making use of the API Explorer or by using Postman. These two techniques are discussed briefly below, but please note that the Auth0 Management API is a REST API, so you can make API calls using anything that can make HTTP requests, or by using one of the Auth0 SDKs.
In order to make requests to the Management API, you will need a token. Please refer to Access Tokens for the Management API for more information.
Search using the API Explorer
To search users using the Management API Explorer, go to the Users section and then select List or search users. Scroll down to the
q parameter. You can use any query string which uses the query string syntax in this field.
Search using Postman
You can also search users using the Postman Collection for the Management API. Make sure you read Using the Auth0 API with our Postman Collections for more information on how to install the collection and also configure your Postman environment correctly.
Once you have downloaded the collection, and configured your environment, select the Management API collection. Navigate to the Users folder and select List or search users. You can enter your query in the
q parameter of the URL:
Sorting search results
To sort the list of users returned from the Management API, you can make use of the
sort parameter. Use the format
field:order for the value of the
sort field, where
field is the name of the field you want to sort by, and
order can be
1 for ascending and
-1 for descending. For example, to sort users in ascending order by the
created_at field you can pass the value of
created_at:1 for the
sort parameter. Sorting by
user_metadata is not supported.
For more information on the
sort and other parameters, please refer to the Management API Explorer documentation.
Exact matching and tokenization
Because of the manner in which ElasticSearch handles tokenization on
-, unexpected results can occur when searching by some fields. For example, when searching for a user whose
name:"jane"), the results will be both for
jane-doe, because both of these contain the exact search term that you used. The difference may not affect some searches, but it will affect others, and provide unanticipated results.
You can solve this problem either by using structured JSON in your metadata, or by using the raw subfield.
If you wish to avoid the potential pitfalls of analyzed data and search for an exact match to your term - an exact string comparison - then for some fields you can use the
raw subfield, which will be
So, in the example
name.raw:"jane", the user data for
jane would match, but
jane-doe would not.
The fields that support
raw subfield queries are:
Below are some example queries to illustrate the kinds of queries that are possible using the Management API V2.
|Search for all users whose name contains "john"||
|Search all users whose name is exactly "john"||
|Search for all user names starting with "john"||
|Search for user names that start with "john" and end with "smith"||
|Search for all users whose email is exactly "firstname.lastname@example.org"||
|Search for all users whose email is exactly "email@example.com" or "firstname.lastname@example.org" using
|Search for users without verified email||
|Search for users who have the
|Search for users from a specific connection or provider||
|Search for all users that have never logged in||
|Search for all users who logged in before 2015||
|Fuzziness: Search for terms that are similar to, but not exactly like,
|All users with more than 100 logins||
|Logins count >= 100 and <= 200||
|Logins count >= 100||
|Logins count > 100 and < 200||
Below is an example request for searching all users whose email is exactly "email@example.com".