Get user by e-mail

AI-generated summary

The discussion revolves around finding a way to retrieve a user by email via the Discourse API. dm.linov asks for an API endpoint to get a user by email, noting that only the reverse (username to email) is documented. codinghorror initially raises privacy concerns but clarifies that with an admin API key, such access is permissible. dm.linov confirms the need for an admin-level solution and later shares a working method using the /admin/users/list/active.json endpoint with email filtering, which allows retrieving users by email address. codinghorror references a guide on reverse-engineering the Discourse API, and dm.linov provides the exact URL and parameters needed for the query.

We are creating users and topics via API. We need to check if a user with such email had been created before. If yes, then we create a topic from the existing user.

So I need an API call “get username by email, if any”. How can I do that? I only found the reverse one.

There’s a link mentioned in several topics, that might have the answer, but it’s broken.
https://meta.discourse.org/t/api-best-way-to-get-user-details-by-email/20806/10

That is a bit of a privacy violation so don’t expect it to be easy.

Why? The admin of the forum can see search user by email via the web interface, what’s the difference if he does the same via API?

Sure if you use an admin api key that should work.

That’s exactly my question. There’s a “Get a single user by username” call in the API docs, but how do I get a single user by email?

Follow the method here since you are an admin and know how to look users up by email address, yes?

Got it, thank you!
Posting it here for anyone else who might need it.
[discourse_url]/admin/users/list/active.json?filter=[email_name]%40[email_domain]&show_emails=false&order=&ascending=&page=1