Auth0 Management API Returns Only 50 Users For A Role

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}/users endpoint

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.

  1. Send the first request with take set to the desired page size. Do not send from on the first request.
  2. Append the users from the response to the results.
  3. Send the next request with from set to the next value if the response includes next. Pass the value unchanged.
  4. Repeat until the response has no next field.

Recommended content

No recommended content found...