# How do I get around the 'get users' 1000 limitation?

**URL:** <https://community.auth0.com/t/how-do-i-get-around-the-get-users-1000-limitation/148041>\
**Category:** Get Help\
**Tags:** user-search, user-management\
**Created:** [September 26, 2024, 3:39pm UTC](https://community.auth0.com/t/how-do-i-get-around-the-get-users-1000-limitation/148041 "2024-09-26T15:39:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![noelt.dolan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/noelt.dolan/32/60288_2.png) [@noelt.dolan](https://community.auth0.com/u/noelt.dolan)\
**Post date:** [September 26, 2024, 3:39pm UTC](https://community.auth0.com/t/how-do-i-get-around-the-get-users-1000-limitation/148041/1 "2024-09-26T15:39:46Z")

</div>

Hi all,

Currently I have a limited number for users, just a couple of hundred, but expect in the coming months for this to rapid increase. As part of my current process, using /api/v2/users endpoint, I can page through, requesting 100 entries each time which all works fine. However with expected increase in mind, I noticed in the api documentation there is a limit of 1000 even with paging! This seems unnecessary, and very restrictive for what I’m sure is a pretty common request. So my question is, using either the SDK or just standard API request, how can I retrieve ALL my users, whether it’s 200, 500, 1000, 5000, etc…?

For context, I’m request all to check for a specific boolean key/value in user\_metadata, which at any point can have true|false|undefined. The number of users for any of these possibilities could, as user numbers increase, be easily 1000+

For referennce, [Auth0 Management API v2](https://auth0.com/docs/api/management/v2/users/get-users)  
`400` You can only page through the first 1000 records.  
See [https://auth0.com/docs/users/search/v3/view-search-results-by-page#limitation](https://auth0.com/docs/users/search/v3/view-search-results-by-page#limitation).

Thank you in advance,

Noel

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [September 26, 2024, 6:19pm UTC](https://community.auth0.com/t/how-do-i-get-around-the-get-users-1000-limitation/148041/3 "2024-09-26T18:19:17Z")

</div>

Hi @noelt.dolan,

I recommend using the [User Import/Export extension](https://auth0.com/docs/extensions/user-import-export) or the [export job](https://auth0.com/docs/api/management/v2#!/Jobs/post_users_exports) to get the complete list of your users without limit.

This workaround is also mentioned in our [Auth0 Management API v2](https://auth0.com/docs/api/management/v2/users/get-users) documentation.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![noelt.dolan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/noelt.dolan/32/60288_2.png) [@noelt.dolan](https://community.auth0.com/u/noelt.dolan)\
**Post date:** [September 27, 2024, 3:53pm UTC](https://community.auth0.com/t/how-do-i-get-around-the-get-users-1000-limitation/148041/4 "2024-09-27T15:53:31Z")

</div>

The above suggested solution, ‘export job’, worked, but had it’s own quirks, see below for how I handled this in typescript. It may be useful and help someone else avoid some pain with this. Assumption that you’ve already setup appropriate auth0 variables AUTH0… When I says quirks, I’m specifically referring to questionable way in which the json response is delivered. 🤔

```auto
import { GetConnectionsStrategyEnum, ManagementClient } from 'auth0';
import { setTimeout } from 'timers/promises';

const management = new ManagementClient({
  domain: AUTH0_USER_MANAGEMENT_DOMAIN,
  clientId: AUTH0_USER_MANAGEMENT_CLIENT_ID,
  clientSecret: AUTH0_USER_MANAGEMENT_CLIENT_SECRET,
});

const doGetAuth0Users = async() => {
  // To make a request to export our users, we first need to find the connection id for our 'auth0' account.
  const connections = await management.connections.getAll({ 
    strategy: [GetConnectionsStrategyEnum.auth0],
   });
  const { data } = connections;

  // there should just be exactly one entry so 'safe' to use 'find'...
  const auth0connection = data.find((d) => d.strategy === GetConnectionsStrategyEnum.auth0 && d.name === 'Username-Password-Authentication');

  // now, submit export users job request...
  const exportUsersJob = await management.jobs.exportUsers({
    connection_id: auth0connection?.id,
    format: 'json',
    fields: [
      { name: 'user_id', export_as: 'userId' },
      { name: 'email', export_as: 'emailAddress' },
      { name: 'user_metadata.account_id', export_as: 'accountId' },
    ]
   });

  // now wait for export users job status completed...
  const users: any[] = [];
  let jobCompleted = false;
  while (!jobCompleted) {
    await setTimeout(5000); // wait 5 seconds for job to complete...
    const job = await management.jobs.get({ id: exportUsersJob.data.id });

    if (job.data.status === 'completed') {      
      const res = await fetch(job.data.location); // job.data.location is a .gz file on AWS S3
      
      const blob = await res.blob(); // this blob is a compressed gz stream, so we need to decompress it...

      const ds = new DecompressionStream('gzip');
      const decompressedStream = blob.stream().pipeThrough(ds);

      // bizarrely, we don't get a proper 'json' response for this, instead we get X text rows, each of which has to be parsed into an JSON object!
      const rows = (await new Response(decompressedStream).text()).split('\n');

      for (let i = 0; i < rows.length; i++) {
        if (!(rows[i]) || rows[i]?.length === 0 ) { // oh! it also returns an empty line at the bottom of the response!
          continue;
        }
        const user = JSON.parse(rows[i] || '{}' );

        users.push(user);
      }

      jobCompleted = true; // this should end the while loop as job request is completed!
    }
  }
  console.log(`users found: ${users.length}`);
  console.table(users);
}

doGetAuth0Users();

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [October 11, 2024, 3:54pm UTC](https://community.auth0.com/t/how-do-i-get-around-the-get-users-1000-limitation/148041/5 "2024-10-11T15:54:08Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [November 26, 2024, 12:22am UTC](https://community.auth0.com/t/how-do-i-get-around-the-get-users-1000-limitation/148041/6 "2024-11-26T00:22:26Z")

</div>

Hi @noelt.dolan,

Thanks for sharing your findings with the rest of the Community!

I am certain this will help other community members experiencing the same issue.

Let us know if you have any additional questions.

Thanks,  
Rueben
