Roles
API for managing account- and course-level roles, and their associated permissions.
A RolePermissions object looks like:
A Role object looks like:
RoleOverridesController#api_index
GET /api/v1/accounts/:account_id/roles
GET /api/v1/accounts/:account_id/roles
Scope: url:GET|/api/v1/accounts/:account_id/roles
A paginated list of the roles available to an account.
Request Parameters:
account_id
Required string
The id of the account to retrieve roles for.
state[]
string
Filter by role state. If this argument is omitted, only ‘active’ roles are returned.
Allowed values: active
, inactive
show_inherited
boolean
If this argument is true, all roles inherited from parent accounts will be included.
Returns a list of Role objects.
GET /api/v1/accounts/:account_id/roles/:id
GET /api/v1/accounts/:account_id/roles/:id
Scope: url:GET|/api/v1/accounts/:account_id/roles/:id
Retrieve information about a single role
Request Parameters:
account_id
Required string
The id of the account containing the role
role_id
Required integer
The unique identifier for the role
role
string
The name for the role
Returns a Role object.
RoleOverridesController#add_role
POST /api/v1/accounts/:account_id/roles
POST /api/v1/accounts/:account_id/roles
Scope: url:POST|/api/v1/accounts/:account_id/roles
Create a new course-level or account-level role.
Request Parameters:
label
Required string
Label for the role.
role
string
Deprecated alias for label.
base_role_type
string
Specifies the role type that will be used as a base for the permissions granted to this role.
Defaults to ‘AccountMembership’ if absent
Allowed values: AccountMembership
, StudentEnrollment
, TeacherEnrollment
, TaEnrollment
, ObserverEnrollment
, DesignerEnrollment
permissions[<X>][explicit]
boolean
no description
permissions[<X>][enabled]
boolean
If explicit is 1 and enabled is 1, permission <X> will be explicitly granted to this role. If explicit is 1 and enabled has any other value (typically 0), permission <X> will be explicitly denied to this role. If explicit is any other value (typically 0) or absent, or if enabled is absent, the value for permission <X> will be inherited from upstream. Ignored if permission <X> is locked upstream (in an ancestor account).
May occur multiple times with unique values for <X>. Recognized permission names for <X> are:
Some of these permissions are applicable only for roles on the site admin account, on a root account, or for course-level roles with a particular base role type; if a specified permission is inapplicable, it will be ignored.
Additional permissions may exist based on installed plugins.
A comprehensive list of all permissions are available:
permissions[<X>][locked]
boolean
If the value is 1, permission <X> will be locked downstream (new roles in subaccounts cannot override the setting). For any other value, permission <X> is left unlocked. Ignored if permission <X> is already locked upstream. May occur multiple times with unique values for <X>.
permissions[<X>][applies_to_self]
boolean
If the value is 1, permission <X> applies to the account this role is in. The default value is 1. Must be true if applies_to_descendants is false. This value is only returned if enabled is true.
permissions[<X>][applies_to_descendants]
boolean
If the value is 1, permission <X> cascades down to sub accounts of the account this role is in. The default value is 1. Must be true if applies_to_self is false.This value is only returned if enabled is true.
Example Request:
Returns a Role object.
RoleOverridesController#remove_role
DELETE /api/v1/accounts/:account_id/roles/:id
DELETE /api/v1/accounts/:account_id/roles/:id
Scope: url:DELETE|/api/v1/accounts/:account_id/roles/:id
Deactivates a custom role. This hides it in the user interface and prevents it from being assigned to new users. Existing users assigned to the role will continue to function with the same permissions they had previously. Built-in roles cannot be deactivated.
Request Parameters:
role_id
Required integer
The unique identifier for the role
role
string
The name for the role
Returns a Role object.
RoleOverridesController#activate_role
POST /api/v1/accounts/:account_id/roles/:id/activate
POST /api/v1/accounts/:account_id/roles/:id/activate
Scope: url:POST|/api/v1/accounts/:account_id/roles/:id/activate
Re-activates an inactive role (allowing it to be assigned to new users)
Request Parameters:
role_id
Required integer
The unique identifier for the role
role
Deprecated
The name for the role
Returns a Role object.
RoleOverridesController#update
PUT /api/v1/accounts/:account_id/roles/:id
PUT /api/v1/accounts/:account_id/roles/:id
Scope: url:PUT|/api/v1/accounts/:account_id/roles/:id
Update permissions for an existing role.
Recognized roles are:
TeacherEnrollment
StudentEnrollment
TaEnrollment
ObserverEnrollment
DesignerEnrollment
AccountAdmin
Any previously created custom role
Request Parameters:
label
string
The label for the role. Can only change the label of a custom role that belongs directly to the account.
permissions[<X>][explicit]
boolean
no description
permissions[<X>][enabled]
boolean
permissions[<X>][applies_to_self]
boolean
If the value is 1, permission <X> applies to the account this role is in. The default value is 1. Must be true if applies_to_descendants is false. This value is only returned if enabled is true.
permissions[<X>][applies_to_descendants]
boolean
If the value is 1, permission <X> cascades down to sub accounts of the account this role is in. The default value is 1. Must be true if applies_to_self is false.This value is only returned if enabled is true.
Example Request:
Returns a Role object.
This documentation is generated directly from the Canvas LMS source code, available on Github.
Last updated