Cases when admin/users.json?email=foobar or admin/users/list/all.json?email=foobar return empty array

Hi,

Per titled, when I run above endpoints I got [] response in Postman. Almost all [] if users foobar has no topic created, but there’s one user who has just created a topic the above query response with [] too, while I think both of them should always return users info as those basic info (registered ip, user name) are users info when they just created their account.

BTW, I cannot find endpoint of admin/users.json in https://docs.discourse.org/. Is it removed and supposed not to use anymore. Thanks!

1 Like

There is also this endpoint /admin/users/list/{flag}.json you can use.

To filter by email you can do:

http://localhost:4200/admin/users/list/active.json?filter=name%40example.com&show_emails=true&order=&asc=&page=1

I’ll review the api docs for these endpoints and see if we need to make some updates.

Hi @blake,

What if I still call admin/users.json, will I get 404 or I can keep using it in my code. My discourse installation version is 3.4.0.beta2, means I can still use admin/users.json?

Wired thing is I cannot find the admin/users/list/all.json?email in the https://docs.discourse.org/.

Ya its totally fine. You can keep using /admin/users.json. It uses the exact same underlying code as as /admin/users/list/{flag}.json. That’s probably one of the reasons it hasn’t been documented yet.

I’m able to get /admin/users.json to return a brand new user without any topics.

curl -i -sSL -X GET "http://localhost:4200/admin/users.json?email=982f145c7@example.com"  \
-H "Api-Key: ..."  \
-H "Api-Username: blake"

HTTP/1.1 200 OK

[
  {
    "id": 2731,
    "username": "982f145c7",
    "name": "982f145c7",
    "avatar_template": "/letter_avatar_proxy/v4/letter/9/46a35a/{size}.png",
    "active": true,
    "admin": false,
    "moderator": false,
    "last_seen_at": null,
    "last_emailed_at": null,
    "created_at": "2025-04-29T12:31:52.894Z",
    "last_seen_age": null,
    "last_emailed_age": null,
    "created_at_age": 103.259451,
    "trust_level": 1,
    "manual_locked_trust_level": null,
    "title": null,
    "time_read": 0,
    "staged": false,
    "can_be_deleted": true,
    "silence_reason": "",
    "days_visited": 0,
    "posts_read_count": 0,
    "topics_entered": 0,
    "post_count": 0
  }
]

You do need to make sure you use the exact email address or you will get an empty array as a result.

Thank you @blake. It’s may fault that I didn’t encode mark + in query string, that causes the empty response. With correct encoding the expect results returned.

I assume the same reason for admin/users/list/all.json?email thought it doesn’t appear in docs.

1 Like

That is documented here actually:

https://docs.discourse.org/#tag/Admin/operation/adminListUsers

but all is not a valid “flag” to pass in.

You will need to paginate to get all of the users.

http://localhost:4200/admin/users/list/active.json?show_emails=false&page=1
http://localhost:4200/admin/users/list/active.json?show_emails=false&order=&asc=&page=2
1 Like