The best option to export all users

Hi guys!

We want to export all users once and I am curious which do you think is the best option:

  1. Export extension
  2. Export Endpoint (Bulk User Export: /api/v2/jobs/users-exports + api/v2/jobs/YOUR_JOB_ID)
  3. Get Users Endpoint (GET /api/v2/users)

Is one of these options limit the number of exported users by default (like 10k)?

Thank you!

Hi @ani.seplecan - I would say that it depends upon how many users you have?

If the number of users is low, you can simply use the pagination of the get users endpoint, something like this (using typescript, but the idea is the same for other implementations):

export async function getAllAuth0Users(query: string): Promise<EddyUser[]> {
    const allUsers = await getUsers(0, [], query);
    return allUsers;
}

async function getUsers(page: number = 0, allUsers: EddyUser[] = [], query: string) {
    const pageSize = 50;
    const userPageResults = await auth0.getUsers({
        q: query,
        per_page: pageSize,
        include_totals: true,
        page,
    });
    userPageResults.users.forEach(user => allUsers.push(user as EddyUser));
    const totalPages = Math.floor(userPageResults.total / pageSize);
    const currentPage = userPageResults.start / pageSize;
    if (totalPages === currentPage) {
        return allUsers;
    } else {
        return getUsers(currentPage + 1, allUsers, query);
    }
}

This approach will hold users in memory. If you have more users, then you need to use the extension or the export job.

Thanks Alex for the prompt response!

Well, we will have many users so that’s why I want to be sure that the option we choose doesn’t have a limit.

Do you if there are differences between the extension and the export job? (related to the number of exported users… or performance)

I don’t have experience with the extension job. But if this is a one-time thing I would go with the export job. Looks responsible simple to me :slight_smile:

Does somebody know if we can schedule the Export Users Extension?

Hi @ani.seplecan . I just looked through the documentation of the export users extension, and could not find anything about schedules. But you can write a script that uses the mangement API to export the users, and then schedule that script?