Auth0 get multiple user data from a single request

I have a scenario where I need to fetch the last login data for all users in Auth0, based on email addresses stored in MongoDB. Currently, I am using the following approach:

await axios.request({
  method: 'GET',
  url: `https://${process.env.AUTH0_DOMAIN}/api/v2/users-by-email`,
  params: { email: user.email },
  headers: { authorization: `Bearer ${accessToken}` }
});

However, with 10K users, I need to retrieve the last login data for each email address efficiently. What is the best optimized and scalable solution for this scenario, considering the need to handle a large number of users? Ideally, the solution should support pagination with a minimum limit of 500.

Hi @swasthiksuvarna2001

Welcome to the Auth0 Community!

Thank you for posting your question, we have an endpoint to retrieve users in bulk → Retrieve Users with the Get Users Endpoint the only issue with that is the limitations. The GET /api/v2/usersendpoint allows 50 users per page and up to 1000 users per search criteria.

Depending on your use case for this issue, you could consider exporting users via job → Auth0 Management API v2 or user import/export extension → User Import / Export Extension and run custom webhook to update fields in your database.

Thanks
Dawid