# How to search all users using certain search criteria within user\_metadata?

**URL:** <https://community.auth0.com/t/how-to-search-all-users-using-certain-search-criteria-within-user-metadata/81449>\
**Category:** Get Help\
**Tags:** api, users, auth0\
**Created:** [April 8, 2022, 1:27pm UTC](https://community.auth0.com/t/how-to-search-all-users-using-certain-search-criteria-within-user-metadata/81449 "2022-04-08T13:27:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![selvi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/selvi/32/33945_2.png) [@selvi](https://community.auth0.com/u/selvi)\
**Post date:** [April 8, 2022, 1:27pm UTC](https://community.auth0.com/t/how-to-search-all-users-using-certain-search-criteria-within-user-metadata/81449/1 "2022-04-08T13:27:46Z")

</div>

I would like to search all users which match certain search criteria within user\_metadata. How should I go about doing this?

i.e. search all Auth0 users using UsersPage or equivalent function which allows us to filter users based on key/value pairs defined in user\_metadata?

// sample scenarios  
**Scenario 1:**

Auth0 organization feature is **available** and veeDNA authentication module will use it

The above implies there will be a **separate** organization for each tenant

auth0-org-a, user-a1 metadata will contain the mapping for tenant-id-a

auth0-org-a, user-a2 metadata will contain the mapping for tenant-id-a

auth0-org-b, user-b1 metadata will contain the mapping for tenant-id-b

auth0-org-b, user-b2 metadata will contain the mapping for tenant-id-b

i.e. each Auth0 organization will contain its own users

**Scenario 2:**

Auth0 organization feature is available and veeDNA authentication module will use it

We will use a **single**  **organization** for all tenants

**auth0-org** , user-a1 metadata will contain the mapping for tenant-id-a

**auth0-org** , user-a2 metadata will contain the mapping for tenant-id-a

**auth0-org** , user-b1 metadata will contain the mapping for tenant-id-b

**auth0-org** , user-b2 metadata will contain the mapping for tenant-id-b

i.e. the **only**  **default** Auth0 organization will contain **all** users

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [April 8, 2022, 7:26pm UTC](https://community.auth0.com/t/how-to-search-all-users-using-certain-search-criteria-within-user-metadata/81449/3 "2022-04-08T19:26:54Z")

</div>

Hi @selvi,

Thanks for reaching out to the Auth0 Community!

I understand that you would like to search all users and filter them by _user\_metadata_.

To do so, you can use the [Management API List or Search Users endpoint](https://auth0.com/docs/api/management/v2#!/Users/get_users) to query for the user’s _user\_metadata_.

In the `q` parameter of the request, filter for the _user\_metadata_ using the following syntax:

```auto
_exists_:user_metadata.YOUR_KEY

```

For example, if the user’s _user\_metadata_ looks like the following:

```auto
//user_metadata
{
   "fav_color": "green",
   "authorization": {
     "admin": true
   }
}

```

You could query for the `fav_color` by making this request:

```auto
_exists_:user_metadata.fav_color

```

This request returns the value `"green"`. You could also query for the values within a nested object:

```auto
_exists_:user_metadata.authorization.admin

```

This request returns the value `true`.

With that, you can search all users and filter them by _user\_metadata_.

Next, from your proposed scenarios, I suggest using a single Organization (Scenario 2) if all the “tenants” belong to the same Organization. Otherwise, you will have to isolate them in different Organizations.

Lastly, note that the _user\_metadata_ is stored in the user’s profile and not in the Organization. Therefore, how you configure the Organization feature should be separate from searching all users and filtering them by _user\_metadata_.

Hoped this helps!

Please let me know if you have any additional questions.

Thank you.

---

<div class="post-metadata">

**Author:** ![selvi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/selvi/32/33945_2.png) [@selvi](https://community.auth0.com/u/selvi)\
**Post date:** [April 11, 2022, 9:19am UTC](https://community.auth0.com/t/how-to-search-all-users-using-certain-search-criteria-within-user-metadata/81449/4 "2022-04-11T09:19:07Z")

</div>

Thanks for the information. Helpful!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 21, 2022, 4:05pm UTC](https://community.auth0.com/t/how-to-search-all-users-using-certain-search-criteria-within-user-metadata/81449/5 "2022-12-21T16:05:39Z")

</div>


