The Instructure Community will enter a read-only state on November 22, 2025 as we prepare to migrate to our new Community platform in early December.
Read our blog post for more info about this change.
Found this content helpful? Log in or sign up to leave a like!
Which API do I use to read a specific user's subaccounts?
I'm not sure I follow what you're looking for. Users, in and of themselves, do not have sub-accounts (at least as far as I know the system). They can be given an Account Role for a sub-account or enrolled in a course belonging to a sub-account. Are you trying to identify one of these? Perhaps both?
We have courses attached to Subaccounts. We add user's to those subaccounts to they can have access of varying levels to different courses. I see these - Canvas Live API , but I do not see a way in any of these to read the end user's list of subaccounts to which they belong. I can remove a user from subaccounts, I can place a user withing subaccounts...but I see no way to simply see the end user's subaccounts.
Is that clearer? Sorry it didn't make sense the first time. ![]()
Alright, so you're trying to get a list of the Account Roles a user has. This...is a bit frustrating to do, but doable.
In short, what you need to do is use the Admins API to retrieve a list of Account Roles assigned to a user. The API supports filtering by user_id, so that's relatively easy. Next, you need to use the Accounts API to retrieve a list a sub-accounts and for each of these, repeat the process, continuing until the path of sub-accounts is empty.
If you need, I can draw up a small example of how this can be done.
Christopher, this turned out to be very helpful. Fixed the problem I was having and enlightened me further in the APIs! Thank you!
That's great to hear! I am curious, were you able to get the results you needed as I identified, or did you come up with a better way of doing it?
Christopher,
I programmed a way to find the subaccount admins for each subaccount, based upon my understanding of the APIs. Not sure if it is exactly like you said, but without your information and suggestion it would not have been as straightforward. I know something I didn't before Tuesday thanks to you.
Here's what I did with it, using two new URIs, after creating a new class and tweaking a couple of other classes (strARG_1 is the appropriate dynamic argument to give me the results I need -
strURI = "https://canvas.park.edu/api/v1/accounts/" + strARG_1 + "/sub_accounts?per_page=100&";
strURI = "https://canvas.park.edu/api/v1/accounts/sis_account_id:" + strARG_1 + "/admins?per_page=100&";
That's about what I summed up, though if you're using it to look for a particular user, you could modify the second one to:
strURI = "https://canvas.park.edu/api/v1/accounts/sis_account_id:" + strARG_1 + "/admins?per_page=100&user_id=" + strARG_2;
The idea being that strARG_2 would be the userID you're searching for.
Thanks!
I'll check it out and get back with you. Thanks Christopher!
Community helpTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in