Auth0 Management API Returns Only 50 Users For A Role
Last Updated:
Overview
A call to the GET /api/v2/roles/{id}/users endpoint returns only 50 users, even though the role contains more users. This occurs because the endpoint returns one page per request with a default page size of 50. Resolve this by calling the endpoint in a loop with checkpoint pagination until the response no longer includes a next value.
Applies To
- Auth0
- Management API v2
GET /api/v2/roles/{id}/usersendpoint
Cause
The endpoint returns one page per request, and the default page size is 50. A single call without a pagination loop returns a maximum of 50 users. The value of 50 represents a page size, not a limit on the number of users a role can hold. This is unrelated to the limit of 50 roles per user. Auth0 does not honor a very large take value because take has an upper limit. The request succeeds and returns the default page of 50. Offset pagination (page and per_page) caps at 1,000 total users for a role. Retrieving more than 1,000 users requires checkpoint pagination (take and from).
Solution
How does an administrator use checkpoint pagination to retrieve all users in a role?
Call the endpoint in a loop with checkpoint pagination and continue until the response no longer includes a next value by executing the following API requests.
- Send the first request with
takeset to the desired page size. Do not sendfromon the first request. - Append the users from the response to the results.
- Send the next request with
fromset to thenextvalue if the response includesnext. Pass the value unchanged. - Repeat until the response has no
nextfield.