Searching users using metadata values as search criteria

I am trying to find a way to search users using certain values in the metadata fields. From what I have read and understood so far, the query string for searching for any field should be something like app_metadata.<property name>:<search value>. But when I run this query in the API explorer, I get an empty response:

Here’s the response for reference:

Request: https://REDACTED.auth0.com/api/v2/users?page=0&per_page=20&include_totals=true&q=app_metadata.sa-user-id%3A1234&search_engine=v3

Query string: app_metadata.sa-user-id:1234

Here, sa-user-id is a custom field in app metadata with a string value 1234.

Response:

{
  "start": 0,
  "limit": 20,
  "length": 0,
  "users": [],
  "total": 0
}

I have checked and rechecked and the values I have passed and the field and property names are correct, but I still get an empty response.

I have refered to the following resources:

But none of these are helpful as to what the correct syntax is or why the response is blank.

If I am doing something wrong, can someone please let me know what’s the correct way to search metadata fields?

Hi @Sargent_D ,

Thank you for posting this topic on the Auth0 Community!

I tested the Search endpoint and it works for me. Here are the details.

image

q: app_metadata.sa-user-id:"1234"

Could you please try adding double quotes around 1234 and see if it works? Thank you.

That’s weird, it didn’t work for me the last time even with the quotes but it works now. Perhaps it was an issue with the API token for the wrong tenant.

My bad, I am pretty new to using the management API.

Glad to know it’s working now :clap: