Find if user is root account admin

Jump to solution
dr2878
Community Novice

how can i find out if a user is AccountAdmin of the ROOT account via REST API? Meaning the master account of all the sub accounts?

Labels (1)
1 Solution
llawson
Community Contributor

Easily enough, all you need is the Admins API endpoint. This will list all admins for whichever account you need to query (in this case just add the root account ID).

GET /api/v1/accounts/:account_id/admins

You can also pass the user_id[] parameter to the query string if you want to see if the user in question exists as an admin under that account.

https://school.instructure.com/api/v1/accounts/self/admins?per_page=100 

Edit: A PowerShell example to get AccountAdmins ONLY:
$res = invoke-restmethod "https://school.instructure.com/api/v1/accounts/self/admins?per_page=100" -method get -headers @{"Authorization" = "Bearer $auth"}
foreach ($r in $res) {
   if ($r.role -like "AccountAdmin") {
     $r
   }
}
‍‍‍‍‍‍‍

View solution in original post