Accounts API
API for accessing account data.
An Account object looks like:
{
// the ID of the Account object
"id": 2,
// The display name of the account
"name": "Canvas Account",
// The account's parent ID, or null if this is the root account
"parent_account_id": 1,
// The ID of the root account, or null if this is the root account
"root_account_id": 1,
// The storage quota for the account in megabytes, if not otherwise specified
"default_storage_quota_mb": 500,
// The storage quota for a user in the account in megabytes, if not otherwise
// specified
"default_user_storage_quota_mb": 50,
// The storage quota for a group in the account in megabytes, if not otherwise
// specified
"default_group_storage_quota_mb": 50,
// The default time zone of the account. Allowed time zones are
// {http://www.iana.org/time-zones IANA time zones} or friendlier
// {http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html Ruby on Rails
// time zones}.
"default_time_zone": "America/Denver",
// The account's identifier in the Student Information System. Only included if the
// user has permission to view SIS information.
"sis_account_id": "123xyz",
// The account's identifier in the Student Information System. Only included if the
// user has permission to view SIS information.
"integration_id": "123xyz",
// The id of the SIS import if created through SIS. Only included if the user has
// permission to manage SIS information.
"sis_import_id": 12,
// The account's identifier that is sent as context_id in LTI launches.
"lti_guid": "123xyz",
// The state of the account. Can be 'active' or 'deleted'.
"workflow_state": "active"
}
List accounts AccountsController#index
GET /api/v1/accounts
List accounts that the current user can view or manage. Typically, students and even teachers will get an empty list in response, only account admins can view the accounts that they are in.
Request Parameters:
Parameter | Type | Description | |
---|---|---|---|
include[] | string |
Array of additional information to include.
Allowed values: |
List accounts for course admins AccountsController#course_accounts
GET /api/v1/course_accounts
List accounts that the current user can view through their admin course enrollments. (Teacher, TA, or designer enrollments). Only returns “id”, “name”, “workflow_state”, “root_account_id” and “parent_account_id”
Returns a list of AccountsGet a single account AccountsController#show
GET /api/v1/accounts/:id
Retrieve information on an individual account, given by id or sis sis_account_id.
Returns a AccountGet 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:
Parameter | Type | Description | |
---|---|---|---|
recursive | boolean |
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>'
List active courses in an account AccountsController#courses_api
GET /api/v1/accounts/:account_id/courses
Retrieve the list of courses in this account.
Request Parameters:
Parameter | Type | Description | |
---|---|---|---|
with_enrollments | boolean |
If true, include only courses with at least one enrollment. If false, include only courses with no enrollments. If not present, do not filter on course enrollment status. |
|
enrollment_type[] | string |
If set, only return courses that have at least one user enrolled in in the course with one of the specified enrollment types.
Allowed values: |
|
published | boolean |
If true, include only published courses. If false, exclude published courses. If not present, do not filter on published status. |
|
completed | boolean |
If true, include only completed courses (these may be in state 'completed', or their enrollment term may have ended). If false, exclude completed courses. If not present, do not filter on completed status. |
|
blueprint | boolean |
If true, include only blueprint courses. If false, exclude them. If not present, do not filter on this basis. |
|
blueprint_associated | boolean |
If true, include only courses that inherit content from a blueprint course. If false, exclude them. If not present, do not filter on this basis. |
|
by_teachers[] | integer |
List of User IDs of teachers; if supplied, include only courses taught by one of the referenced users. |
|
by_subaccounts[] | integer |
List of Account IDs; if supplied, include only courses associated with one of the referenced subaccounts. |
|
hide_enrollmentless_courses | boolean |
If present, only return courses that have at least one enrollment. Equivalent to 'with_enrollments=true'; retained for compatibility. |
|
state[] | string |
If set, only return courses that are in the given state(s). By default, all states but “deleted” are returned.
Allowed values: |
|
enrollment_term_id | integer |
If set, only includes courses from the specified term. |
|
search_term | string |
The partial course name, code, or full ID to match and return in the results list. Must be at least 3 characters. |
|
include[] | string |
Allowed values: |
Update an account AccountsController#update
PUT /api/v1/accounts/:id
Update an existing account.
Request Parameters:
Parameter | Type | Description | |
---|---|---|---|
account[name] | string |
Updates the account name |
|
account[default_time_zone] | string |
The default time zone of the account. Allowed time zones are IANA time zones or friendlier Ruby on Rails time zones. |
|
account[default_storage_quota_mb] | integer |
The default course storage quota to be used, if not otherwise specified. |
|
account[default_user_storage_quota_mb] | integer |
The default user storage quota to be used, if not otherwise specified. |
|
account[default_group_storage_quota_mb] | integer |
The default group storage quota to be used, if not otherwise specified. |
|
account[settings][restrict_student_past_view][value] | boolean |
Restrict students from viewing courses after end date |
|
account[settings][restrict_student_past_view][locked] | boolean |
Lock this setting for sub-accounts and courses |
|
account[settings][restrict_student_future_view][value] | boolean |
Restrict students from viewing courses before start date |
|
account[settings][restrict_student_future_view][locked] | boolean |
Lock this setting for sub-accounts and courses |
|
account[settings][lock_all_announcements][value] | boolean |
Disable comments on announcements |
|
account[settings][lock_all_announcements][locked] | boolean |
Lock this setting for sub-accounts and courses |
|
account[settings][restrict_student_future_listing][value] | boolean |
Restrict students from viewing future enrollments in course list |
|
account[settings][restrict_student_future_listing][locked] | boolean |
Lock this setting for sub-accounts and courses |
|
account[services] | Hash |
Give this a set of keys and boolean values to enable or disable services matching the keys |
Example Request:
curl https://<canvas>/api/v1/accounts/<account_id> \
-X PUT \
-H 'Authorization: Bearer <token>' \
-d 'account[name]=New account name' \
-d 'account[default_time_zone]=Mountain Time (US & Canada)' \
-d 'account[default_storage_quota_mb]=450'
Delete a user from the root account AccountsController#remove_user
DELETE /api/v1/accounts/:account_id/users/:user_id
Delete a user record from a Canvas root account. If a user is associated with multiple root accounts (in a multi-tenant instance of Canvas), this action will NOT remove them from the other accounts.
WARNING: This API will allow a user to remove themselves from the account. If they do this, they won't be able to make API calls or log into Canvas at that account.
Example Request:
curl https://<canvas>/api/v1/accounts/3/users/5 \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
-X DELETE
Create a new sub-account SubAccountsController#create
POST /api/v1/accounts/:account_id/sub_accounts
Add a new sub-account to a given account.
Request Parameters:
Parameter | Type | Description | |
---|---|---|---|
account[name] | Required | string |
The name of the new sub-account. |
account[sis_account_id] | string |
The account's identifier in the Student Information System. |
|
account[default_storage_quota_mb] | integer |
The default course storage quota to be used, if not otherwise specified. |
|
account[default_user_storage_quota_mb] | integer |
The default user storage quota to be used, if not otherwise specified. |
|
account[default_group_storage_quota_mb] | integer |
The default group storage quota to be used, if not otherwise specified. |