How to get all the factors for all users

“{{url}}/api/v1/users/{{userId}}/factors” in the OKTA Factors API gets me all the factors for an individual user.

“{{url}}/api/v1/users?limit=25” in the OKTA Users API gets me all the users in my OKTA domain.

Is there some way to combine these two API calls, such that I can get a JSON of all the users and all their enrolled factors at once?

Use a pagination loop, i.e. for powershell:

$uri = “https://{{url}}/api/v1/users”



$webrequest = Invoke-WebRequest -TimeoutSec 300 -Headers @{“Authorization” = $apiKey} -Method Get -Uri $uri

$link = $webrequest.Headers.Link.Split("<").Split(">")

$uri = $link[3]

$json = $webrequest | ConvertFrom-Json

$allusers += $json

} while ($webrequest.Headers.Link.EndsWith(‘rel=“next”’))

@jleesme and @Govner explains how pagination works.

I have sample PowerShell code (search for Get-MfaUsers in this file):