Files
An API for managing files and folders See the File Upload Documentation for details on the file upload workflow.
A File object looks like:
A Folder object looks like:
An UsageRights object looks like:
A License object looks like:
GET /api/v1/courses/:course_id/files/quota
GET /api/v1/courses/:course_id/files/quota
Scope: url:GET|/api/v1/courses/:course_id/files/quota
GET /api/v1/groups/:group_id/files/quota
GET /api/v1/groups/:group_id/files/quota
Scope: url:GET|/api/v1/groups/:group_id/files/quota
GET /api/v1/users/:user_id/files/quota
GET /api/v1/users/:user_id/files/quota
Scope: url:GET|/api/v1/users/:user_id/files/quota
Returns the total and used storage quota for the course, group, or user.
Example Request:
Example Response:
GET /api/v1/courses/:course_id/files
GET /api/v1/courses/:course_id/files
Scope: url:GET|/api/v1/courses/:course_id/files
GET /api/v1/users/:user_id/files
GET /api/v1/users/:user_id/files
Scope: url:GET|/api/v1/users/:user_id/files
GET /api/v1/groups/:group_id/files
GET /api/v1/groups/:group_id/files
Scope: url:GET|/api/v1/groups/:group_id/files
GET /api/v1/folders/:id/files
GET /api/v1/folders/:id/files
Scope: url:GET|/api/v1/folders/:id/files
Returns the paginated list of files for the folder or course.
Request Parameters:
Parameter | Type | Description |
---|---|---|
|
| Filter results by content-type. You can specify type/subtype pairs (e.g., ‘image/jpeg’), or simply types (e.g., ‘image’, which will match ‘image/gif’, ‘image/jpeg’, etc.). |
|
| Exclude given content-types from your results. You can specify type/subtype pairs (e.g., ‘image/jpeg’), or simply types (e.g., ‘image’, which will match ‘image/gif’, ‘image/jpeg’, etc.). |
|
| The partial name of the files to match and return. |
|
| Array of additional information to include.
Allowed values: |
|
| Array of information to restrict to. Overrides include[]
|
|
| Sort results by this field. Defaults to ‘name’. Note that ‘sort=user |
|
| The sorting order. Defaults to ‘asc’. Allowed values: |
Example Request:
Returns a list of File objects.
GET /api/v1/files/:id/public_url
GET /api/v1/files/:id/public_url
Scope: url:GET|/api/v1/files/:id/public_url
Determine the URL that should be used for inline preview of the file.
Request Parameters:
Parameter | Type | Description |
---|---|---|
|
| The id of the submission the file is associated with. Provide this argument to gain access to a file that has been submitted to an assignment (Canvas will verify that the file belongs to the submission and the calling user has rights to view the submission). |
Example Request:
Example Response:
GET /api/v1/files/:id
GET /api/v1/files/:id
Scope: url:GET|/api/v1/files/:id
POST /api/v1/files/:id
POST /api/v1/files/:id
Scope: url:POST|/api/v1/files/:id
GET /api/v1/courses/:course_id/files/:id
GET /api/v1/courses/:course_id/files/:id
Scope: url:GET|/api/v1/courses/:course_id/files/:id
GET /api/v1/groups/:group_id/files/:id
GET /api/v1/groups/:group_id/files/:id
Scope: url:GET|/api/v1/groups/:group_id/files/:id
GET /api/v1/users/:user_id/files/:id
GET /api/v1/users/:user_id/files/:id
Scope: url:GET|/api/v1/users/:user_id/files/:id
Returns the standard attachment json object
Request Parameters:
Parameter | Type | Description |
---|---|---|
|
| Array of additional information to include.
Allowed values: |
|
| When a user replaces a file during upload, Canvas keeps track of the “replacement chain.”
Include this parameter if you wish Canvas to follow the replacement chain if the requested file was deleted and replaced by another.
Must be set to ‘course’ or ‘account’. The “replacement_chain_context_id” parameter must also be included. |
|
| When a user replaces a file during upload, Canvas keeps track of the “replacement chain.”
Include this parameter if you wish Canvas to follow the replacement chain if the requested file was deleted and replaced by another.
Indicates the context ID Canvas should use when following the “replacement chain.” The “replacement_chain_context_type” parameter must also be included. |
Example Request:
Returns a File object.
GET /api/v1/courses/:course_id/files/file_ref/:migration_id
GET /api/v1/courses/:course_id/files/file_ref/:migration_id
Scope: url:GET|/api/v1/courses/:course_id/files/file_ref/:migration_id
Get information about a file from a course copy file reference
Example Request:
Returns a File object.
PUT /api/v1/files/:id
PUT /api/v1/files/:id
Scope: url:PUT|/api/v1/files/:id
Update some settings on the specified file
Request Parameters:
Parameter | Type | Description |
---|---|---|
|
| The new display name of the file, with a limit of 255 characters. |
|
| The id of the folder to move this file into. The new folder must be in the same context as the original parent folder. If the file is in a context without folders this does not apply. |
|
| If the file is moved to a folder containing a file with the same name, or renamed to a name matching an existing file, the API call will fail unless this parameter is supplied.
Allowed values: |
|
| The datetime to lock the file at |
|
| The datetime to unlock the file at |
|
| Flag the file as locked |
|
| Flag the file as hidden |
|
| Configure which roles can access this file |
Example Request:
Returns a File object.
DELETE /api/v1/files/:id
DELETE /api/v1/files/:id
Scope: url:DELETE|/api/v1/files/:id
Remove the specified file. Unlike most other DELETE endpoints, using this endpoint will result in comprehensive, irretrievable destruction of the file. It should be used with the ‘replace` parameter set to true in cases where the file preview also needs to be destroyed (such as to remove files that violate privacy laws).
Request Parameters:
Parameter | Type | Description |
---|---|---|
|
| This action is irreversible. If replace is set to true the file contents will be replaced with a generic “file has been removed” file. This also destroys any previews that have been generated for the file. Must have manage files and become other users permissions |
Example Request:
Returns a File object.
GET /api/v1/files/:id/icon_metadata
GET /api/v1/files/:id/icon_metadata
Scope: url:GET|/api/v1/files/:id/icon_metadata
Returns the icon maker file attachment metadata
Example Request:
Example Response:
FilesController#reset_verifier
POST /api/v1/files/:id/reset_verifier
POST /api/v1/files/:id/reset_verifier
Scope: url:POST|/api/v1/files/:id/reset_verifier
Resets the link verifier. Any existing links to the file using the previous hard-coded “verifier” parameter will no longer automatically grant access.
Must have manage files and become other users permissions
Example Request:
Returns a File object.
GET /api/v1/folders/:id/folders
GET /api/v1/folders/:id/folders
Scope: url:GET|/api/v1/folders/:id/folders
Returns the paginated list of folders in the folder.
Example Request:
Returns a list of Folder objects.
FoldersController#list_all_folders
GET /api/v1/courses/:course_id/folders
GET /api/v1/courses/:course_id/folders
Scope: url:GET|/api/v1/courses/:course_id/folders
GET /api/v1/users/:user_id/folders
GET /api/v1/users/:user_id/folders
Scope: url:GET|/api/v1/users/:user_id/folders
GET /api/v1/groups/:group_id/folders
GET /api/v1/groups/:group_id/folders
Scope: url:GET|/api/v1/groups/:group_id/folders
Returns the paginated list of all folders for the given context. This will be returned as a flat list containing all subfolders as well.
Example Request:
Returns a list of Folder objects.
FoldersController#resolve_path
GET /api/v1/courses/:course_id/folders/by_path/*full_path
GET /api/v1/courses/:course_id/folders/by_path/*full_path
Scope: url:GET|/api/v1/courses/:course_id/folders/by_path/*full_path
GET /api/v1/courses/:course_id/folders/by_path
GET /api/v1/courses/:course_id/folders/by_path
Scope: url:GET|/api/v1/courses/:course_id/folders/by_path
GET /api/v1/users/:user_id/folders/by_path/*full_path
GET /api/v1/users/:user_id/folders/by_path/*full_path
Scope: url:GET|/api/v1/users/:user_id/folders/by_path/*full_path
GET /api/v1/users/:user_id/folders/by_path
GET /api/v1/users/:user_id/folders/by_path
Scope: url:GET|/api/v1/users/:user_id/folders/by_path
GET /api/v1/groups/:group_id/folders/by_path/*full_path
GET /api/v1/groups/:group_id/folders/by_path/*full_path
Scope: url:GET|/api/v1/groups/:group_id/folders/by_path/*full_path
GET /api/v1/groups/:group_id/folders/by_path
GET /api/v1/groups/:group_id/folders/by_path
Scope: url:GET|/api/v1/groups/:group_id/folders/by_path
Given the full path to a folder, returns a list of all Folders in the path hierarchy, starting at the root folder, and ending at the requested folder. The given path is relative to the context’s root folder and does not include the root folder’s name (e.g., “course files”). If an empty path is given, the context’s root folder alone is returned. Otherwise, if no folder exists with the given full path, a Not Found error is returned.
Example Request:
Returns a list of Folder objects.
GET /api/v1/courses/:course_id/folders/:id
GET /api/v1/courses/:course_id/folders/:id
Scope: url:GET|/api/v1/courses/:course_id/folders/:id
GET /api/v1/users/:user_id/folders/:id
GET /api/v1/users/:user_id/folders/:id
Scope: url:GET|/api/v1/users/:user_id/folders/:id
GET /api/v1/groups/:group_id/folders/:id
GET /api/v1/groups/:group_id/folders/:id
Scope: url:GET|/api/v1/groups/:group_id/folders/:id
GET /api/v1/folders/:id
GET /api/v1/folders/:id
Scope: url:GET|/api/v1/folders/:id
Returns the details for a folder
You can get the root folder from a context by using ‘root’ as the :id. For example, you could get the root folder for a course like:
Example Request:
Returns a Folder object.
PUT /api/v1/folders/:id
PUT /api/v1/folders/:id
Scope: url:PUT|/api/v1/folders/:id
Updates a folder
Request Parameters:
Parameter | Type | Description |
---|---|---|
|
| The new name of the folder |
|
| The id of the folder to move this folder into. The new folder must be in the same context as the original parent folder. |
|
| The datetime to lock the folder at |
|
| The datetime to unlock the folder at |
|
| Flag the folder as locked |
|
| Flag the folder as hidden |
|
| Set an explicit sort position for the folder |
Example Request:
Returns a Folder object.
POST /api/v1/courses/:course_id/folders
POST /api/v1/courses/:course_id/folders
Scope: url:POST|/api/v1/courses/:course_id/folders
POST /api/v1/users/:user_id/folders
POST /api/v1/users/:user_id/folders
Scope: url:POST|/api/v1/users/:user_id/folders
POST /api/v1/groups/:group_id/folders
POST /api/v1/groups/:group_id/folders
Scope: url:POST|/api/v1/groups/:group_id/folders
POST /api/v1/folders/:folder_id/folders
POST /api/v1/folders/:folder_id/folders
Scope: url:POST|/api/v1/folders/:folder_id/folders
POST /api/v1/accounts/:account_id/folders
POST /api/v1/accounts/:account_id/folders
Scope: url:POST|/api/v1/accounts/:account_id/folders
Creates a folder in the specified context
Request Parameters:
Parameter | Type | Description |
---|---|---|
| Required | The name of the folder |
|
| The id of the folder to store the new folder in. An error will be returned if this does not correspond to an existing folder. If this and parent_folder_path are sent an error will be returned. If neither is given, a default folder will be used. |
|
| The path of the folder to store the new folder in. The path separator is the forward slash ‘/`, never a back slash. The parent folder will be created if it does not already exist. This parameter only applies to new folders in a context that has folders, such as a user, a course, or a group. If this and parent_folder_id are sent an error will be returned. If neither is given, a default folder will be used. |
|
| The datetime to lock the folder at |
|
| The datetime to unlock the folder at |
|
| Flag the folder as locked |
|
| Flag the folder as hidden |
|
| Set an explicit sort position for the folder |
Example Request:
Returns a Folder object.
DELETE /api/v1/folders/:id
DELETE /api/v1/folders/:id
Scope: url:DELETE|/api/v1/folders/:id
Remove the specified folder. You can only delete empty folders unless you set the ‘force’ flag
Request Parameters:
Parameter | Type | Description |
---|---|---|
|
| Set to ‘true’ to allow deleting a non-empty folder |
Example Request:
POST /api/v1/folders/:folder_id/files
POST /api/v1/folders/:folder_id/files
Scope: url:POST|/api/v1/folders/:folder_id/files
Upload a file to a folder.
This API endpoint is the first step in uploading a file. See the File Upload Documentation for details on the file upload workflow.
Only those with the “Manage Files” permission on a course or group can upload files to a folder in that course or group.
POST /api/v1/folders/:dest_folder_id/copy_file
POST /api/v1/folders/:dest_folder_id/copy_file
Scope: url:POST|/api/v1/folders/:dest_folder_id/copy_file
Copy a file from elsewhere in Canvas into a folder.
Copying a file across contexts (between courses and users) is permitted, but the source and destination must belong to the same institution.
Request Parameters:
Parameter | Type | Description |
---|---|---|
| Required | The id of the source file |
|
| What to do if a file with the same name already exists at the destination. If such a file exists and this parameter is not given, the call will fail.
Allowed values: |
Example Request:
Returns a File object.
POST /api/v1/folders/:dest_folder_id/copy_folder
POST /api/v1/folders/:dest_folder_id/copy_folder
Scope: url:POST|/api/v1/folders/:dest_folder_id/copy_folder
Copy a folder (and its contents) from elsewhere in Canvas into a folder.
Copying a folder across contexts (between courses and users) is permitted, but the source and destination must belong to the same institution. If the source and destination folders are in the same context, the source folder may not contain the destination folder. A folder will be renamed at its destination if another folder with the same name already exists.
Request Parameters:
Parameter | Type | Description |
---|---|---|
| Required | The id of the source folder |
Example Request:
Returns a Folder object.
FoldersController#media_folder
GET /api/v1/courses/:course_id/folders/media
GET /api/v1/courses/:course_id/folders/media
Scope: url:GET|/api/v1/courses/:course_id/folders/media
GET /api/v1/groups/:group_id/folders/media
GET /api/v1/groups/:group_id/folders/media
Scope: url:GET|/api/v1/groups/:group_id/folders/media
Returns the details for a designated upload folder that the user has rights to upload to, and creates it if it doesn’t exist.
If the current user does not have the permissions to manage files in the course or group, the folder will belong to the current user directly.
Example Request:
Returns a Folder object.
UsageRightsController#set_usage_rights
PUT /api/v1/courses/:course_id/usage_rights
PUT /api/v1/courses/:course_id/usage_rights
Scope: url:PUT|/api/v1/courses/:course_id/usage_rights
PUT /api/v1/groups/:group_id/usage_rights
PUT /api/v1/groups/:group_id/usage_rights
Scope: url:PUT|/api/v1/groups/:group_id/usage_rights
PUT /api/v1/users/:user_id/usage_rights
PUT /api/v1/users/:user_id/usage_rights
Scope: url:PUT|/api/v1/users/:user_id/usage_rights
Sets copyright and license information for one or more files
Request Parameters:
Parameter | Type | Description |
---|---|---|
| Required | List of ids of files to set usage rights for. |
|
| List of ids of folders to search for files to set usage rights for. Note that new files uploaded to these folders do not automatically inherit these rights. |
|
| Whether the file(s) or folder(s) should be published on save, provided that usage rights have been specified (set to ‘true` to publish on save). |
| Required | The intellectual property justification for using the files in Canvas Allowed values: |
|
| The legal copyright line for the files |
|
| The license that applies to the files. See the List licenses endpoint for the supported license types. |
Returns an UsageRights object.
UsageRightsController#remove_usage_rights
DELETE /api/v1/courses/:course_id/usage_rights
DELETE /api/v1/courses/:course_id/usage_rights
Scope: url:DELETE|/api/v1/courses/:course_id/usage_rights
DELETE /api/v1/groups/:group_id/usage_rights
DELETE /api/v1/groups/:group_id/usage_rights
Scope: url:DELETE|/api/v1/groups/:group_id/usage_rights
DELETE /api/v1/users/:user_id/usage_rights
DELETE /api/v1/users/:user_id/usage_rights
Scope: url:DELETE|/api/v1/users/:user_id/usage_rights
Removes copyright and license information associated with one or more files
Request Parameters:
Parameter | Type | Description |
---|---|---|
| Required | List of ids of files to remove associated usage rights from. |
|
| List of ids of folders. Usage rights will be removed from all files in these folders. |
UsageRightsController#licenses
GET /api/v1/courses/:course_id/content_licenses
GET /api/v1/courses/:course_id/content_licenses
Scope: url:GET|/api/v1/courses/:course_id/content_licenses
GET /api/v1/groups/:group_id/content_licenses
GET /api/v1/groups/:group_id/content_licenses
Scope: url:GET|/api/v1/groups/:group_id/content_licenses
GET /api/v1/users/:user_id/content_licenses
GET /api/v1/users/:user_id/content_licenses
Scope: url:GET|/api/v1/users/:user_id/content_licenses
A paginated list of licenses that can be applied
Returns a list of License objects.
© Instructure, Inc. Generated on Wed Nov 6 14:20:07 2024 This documentation is generated directly from the Canvas LMS source code, available on Github.
Last updated