API find email address, or search?

AI-generated summary

The discussion revolves around finding a way to verify if a user with a specific email exists in a Discourse instance via the API. alank initially struggled with API endpoints, noting that admin/users/list/all.json?email=some@email.com didn’t work in their tests, and was concerned about the overhead of fetching all users just to check email existence. RGJ confirmed the endpoint works and suggested using by-external for SSO. alank later discovered that admin/users/list/all.json?email=email@example.com actually returns only the matching user, making it efficient for email verification. RGJ clarified that the query does not pull all users, and alank confirmed this approach resolves the issue.

I’ve read a discourse post, thinking I had found it " SITENAME.com/admin/users/list/all.json?email=some@email.com which is what I need, that is verify if our SSO site has a Discourse member, via query of the Discourse API (from our API) but how, as the link above doesn’t work and if I could simply get a list of all users I’d implement the filter/result based on email address.

I think this is very protected or non-accessable, or is there a way?

That route should still work (just tested it).

For SSO you could also use by-external.
See Discourse API Docs

@RGJ you are right! It does work!!! Something with my Postman requests tests are broken. :frowning:

However with SuperAgent request such as:

let res = await superagent.get(`${this.baseUrl}/admin/users/list/active`)
          .query({show_emails: true})
          .set('Api-Key', this.apiKey)
          .set('Api-Username', this.defaultDiscourseUser)
          .set('Content-Type', 'application/json')
          .set('Accept', 'application/json')

I was able to get the emails.

My apologies, however it would be nice to have an API request that simply returns true/false if an email exists, for now I’m pulling all users (a response that is a little heavy since it returns all user info) while all I want is to verify if the email exists - in fact I just want a true/false from Discourse if the user has logged in there first before coming to our site.

With

superagent.get(`${this.baseUrl}/admin/users/list/all.json?email=${emailAddress}`)

you’re not pulling all the users.

Oh wow, thanks for that! This will get only one user and email? Works for me! Great!!!