Hey Viktor,
I assume you are using the GetUserByEmail endpoint from the Auth0 Management API. Unfortunately, as of right now, I don’t think there is a way to filter even more. Once the endpoint is hit, an object is returned with all identities which match the specific email. This means, if a user has one identity in Database A and another identity in Database B, both of which have the same email, then when calling this endpoint, the returned value will be an array of both identities.
For example, say in Database A I create a user with the following values:
{
"email": "john.doe@gmail.com",
"given_name": "John",
"family_name": "Doe",
"name": "John Doe",
"connection": "ConnectionA",
"password": "secret",
}
and in Database B I create the exact same user, however, the connection is different:
{
"email": "john.doe@gmail.com",
"given_name": "John",
"family_name": "Doe",
"name": "John Doe",
"connection": "ConnectionB",
"password": "secret",
}
Now when I call the Management API’s /api/v2/users-by-email endpoint, and enter the following email john.doe@gmail.com, it will return the following object containing both identities:
[
{
"created_at": "2021-09-08T15:21:51.912Z",
"email": "john.doe@gmail.com",
"email_verified": false,
"identities": [
{
"connection": "DatabaseA",
"user_id": "6138d...eee811",
"provider": "auth0",
"isSocial": false
}
],
"name": "John Doe",
"user_id": "auth0|6138d...eee811"
},
{
"created_at": "2021-09-08T15:21:51.912Z",
"email": "john.doe@gmail.com",
"email_verified": false,
"identities": [
{
"connection": "DatabaseB",
"user_id": "6138d...eee812",
"provider": "auth0",
"isSocial": false
}
],
"name": "John Doe",
"user_id": "auth0|6138d...eee812"
}
]
Please let me know if this makes sense or if you have any other questions, and ill be happy to help