Auth0 Home Blog Docs

Is it possible to use api to search for user by phone number?



I’d like to search for a user by the phone number in identities[n].profileData.phone_number, where identities[n] would have connection type sms, and n is unknown (whichever one has connection type sms)

Is this possible to do with the api? I can’t get it to work playing around with the lucene-style queries…


I noticed that you can search users by phone number on the users page in the dashboard, but it does not look at identities[n].profileData.phone_number. It just looks at the top level


Made a quick test and I was also not able to query the linked user profile data; I will have to look into this further as I’m not that knowledgeable in the search query syntax so I might be missing something. I will let you know if I find anything relevant.


thanks @jmangelo

What I am doing is using the API to create an sms user, and don’t want to make the call if the phone number is already being used by another user


Yeah, that’s a fair use case. By purely reading the docs it sounds like it should work, however, my test tenant was not in equivalent (from the perspective of user search) configuration as to yours so I’m waiting to get it at that level so I can test under the same conditions.


thanks @jmangelo

It actually would seem to make more sense to return 400 if the phone number is in use, like it seems to do when creating a username/pw user with an email and the email is already in use.

Currently, if the phone number is in use, the create call seems to return a structure that contains the user id of the existing user with that phone number, which is weird