AnsweredAssumed Answered

REST API CURL How Do I Get sub_accounts recursively

Question asked by Larry Robertson on Apr 19, 2019
Latest reply on May 13, 2019 by James Jones

I am new to the Canvas API and I can't seem to get CURL to return anything within a particular sub account.

The sub accounts I'm dealing contain courses which have been imported from a CVS file.


So far this is what I have that is working:


curl -H "Authorization: Bearer <access token>" "/api/v1/accounts/1/sub_accounts"


The following JSON is returned, to simplify I will only show the first item:

[{"id":2,"name":"Canvas Demo Courses","workflow_state":"active","parent_account_id":1,"root_account_id":1,"uuid":"q4CGtwHqU35Nw9U2dr4HtOa7TWKnKJezee33cWnG","default_storage_quota_mb":10000,"default_user_storage_quota_mb":50,"default_group_storage_quota_mb":5000,"default_time_zone":"America/New_York","sis_account_id":"canvas-sdemo","sis_import_id":1,"integration_id":null}]


Here a snip-it from the documentation that I am trying to figure out how to code using curl I don't know how to specify recursive=true on the command line because the example doesn't show how.

Get the sub-accounts of an account AccountsController#sub_accounts
GET /api/v1/accounts/:account_id/sub_accounts
List accounts that are sub-accounts of the given account.

Request Parameters:
If true, the entire account tree underneath

this account will be returned (though still paginated). If false, only direct sub-accounts of this account will be returned. Defaults to false.

Example Request:
curl https://<canvas>/api/v1/accounts/<account_id>/sub_accounts \
-H 'Authorization: Bearer <token>'


My Goal

Again to simplify things I'm not concerned with pagination I will handle all of that later, so let me stick with the item shown above.

  1. From within the Canvas Admin Tab if I click on Sub-Accounts I am presented with a list of courses.
  2. If I click on the settings gear next to one of the listed courses I get an HTML form page that contains the Course Details; Name, Course Code, Blueprint Course, Time Zone, SIS ID, Subaccount...  This is the data I need to GET I would like to be able to edit this data and then PUT or update the changes that I make programmatically.



  1. Can anyone get me started by first telling me if this is even possible?
  2. And then by showing me how to implement recursive from the command line?