Auth0 Home Blog Docs

Get mulitple users by IDs

If I have a collection of user_id, is it possible to retrieve ALL of those users from auth0 in one go? Or do I call GET /api/v2/users/{id} for each id individually?

use case:
Basically, I have a database with a table called Documents.
I also have a relational table called Document_Users, which contains user_id and a foreign key document_id. This allows the given auth0 user to read/write the document record.

But I want to see a list of all users who can access a document, and display their name… not just their user id.

Hey @truescope,

For the functionality you describe, it’s better to store the data in your database instead of querying Auth0 to get profile information for other users that are not the user actually logged in into the application.

Our Data Storage Best Practices document details the reasons why you should consider using your own database for use-cases that are not related to an authentication event:

The Auth0 data store is customized for authentication data. Storing anything beyond the default user information should be done only in limited cases. Here’s why:

  • Scalability : The Auth0 data store is limited in scalability, and your Application’s data may exceed the appropriate limits. By using an external database, you keep your Auth0 data store simple, while the more efficient external database contains the extra data;
  • Performance : Your authentication data is likely accessed at lower frequencies than your other data. The Auth0 data store isn’t optimized for high frequency use, so you should store data that needs to be retrieved more often elsewhere;
  • Flexibility : Because the Auth0 data store was built to accommodate only user profiles and their associated metadata, you are limited in terms of the actions you can perform on the database. By using separate databases for your other data, you can manage your data as appropriate.

I hope this helps!