Drive API

The Drive API helps you manage my drive, collaborative drives, and team/group folders.

To use the Drive API, you need an access token that you can get by authenticating with a user account, not a service account. Available API operations may vary depending on your pricing plan.

The API scopes are as follows:

  • file or file.read : All Drive API operations are available.
  • group.folder or group.folder.read : Only the Drive API operations associated with Team/Group Folder are available.

How to use the Drive API {#user-drive-api}

There are separate groups of Drive API operations for my drive, collaborative drives, and team/group folders, but you can use them in a similar way. Different API operations are available for each drive type: API operations to manage permission are not available for my drive, while API operations to create and delete a drive are available only for collaborative drives.

For both drive types, different API operations are available to upload files, get files, and create folders for the root folder and the rest of the folders.

To access a folder or file in a drive, you need to first get files of the root folder to get its ID and use it to make an API call based on the folder hierarchy. If you already know the parameter required to access a file or folder, such as sharedriveId and fileId, you can access it right away.


Manage drives {#manage-drive}

Manage my drive {#manage-mydrive}

No preparation is required to use my drive.
You can check the usage of my drive using the Drive API.
A member has only one "my drive," so there are no API operations to get drives and to manage permissions.

HTTP requestDescription
GET /users/{userId}/driveMy drive - Get properties

Manage collaborative drives {#manage-sharedrive}

You can manage collaborative drives on the desktop or mobile app as well as through the following API operations.

HTTP requestDescription
POST /sharedrivesCreate a collaborative drive
GET /sharedrivesGet collaborative drives
GET /sharedrives/{sharedriveId}Get a collaborative drive
PATCH /sharedrives/{sharedriveId}Update a collaborative drive
DELETE /sharedrives/{sharedriveId}Delete a collaborative drive

Manage team/group folders {#manage-groupfolder}

A team/group folder is part of the team and group features. You can enable or disable this feature using the useFolder property of the API operation that manages teams or groups.

Managing teams requires the orgunit or directory scope, and managing groups requires the group or directory scope.

HTTP requestDescription
POST /orgunitsAdd a team
PUT /orgunits/{orgUnitId}Update a team
PATCH /orgunits/{orgUnitId}Update part of a team
HTTP requestDescription
POST /groupsAdd a group
PUT /groups/{groupId}Update a group
PATCH /groups/{groupId}Update part of a group

Use the following API operation to check the usage of team/group folders.
You can access a team/group folder by specifying orgUnitId or groupId, as there is no team/group folder ID.

HTTP requestDescription
GET /groups/{groupId}/folderTeam/group - Get folder properties

To use a team/group folder after enabling it using useFolder, you need to create a folder using the following API operation.

HTTP requestDescription
POST /groups/{groupId}/folderTeam/group folder - Create a folder

Even if you disable the team/group folder using useFolder, the folder data will remain unchanged. To actually delete the folder data, you need to use the following API operation.

HTTP requestDescription
DELETE /groups/{groupId}/folderTeam/group - Delete a folder

Manage folders shared by me {#manage-sharefolder}

You can manage folders shared by me on the desktop or mobile app as well as through the following API operations.

HTTP requestDescription
GET /users/{userId}/drive/files/{fileId}/shareGet folder sharing
POST /users/{userId}/drive/files/{fileId}/shareShare a folder
PATCH /users/{userId}/drive/files/{fileId}/shareUpdate folder sharing
DELETE /users/{userId}/drive/files/{fileId}/shareUnshare a folder
GET /users/{userId}/drive/files/{fileId}/share-sub-foldersGet collaborative subfolders

Manage folders shared with me {#manage-sharedfolder}

You can manage folders shared with me on the desktop or mobile app as well as through the following API operations.

HTTP requestDescription
GET /users/{userId}/drive/sharedfoldersGet shared folders
DELETE /users/{userId}/drive/sharedfolders/{sharedFolderId}Delete a shared folder
GET /users/{userId}/drive/sharedfolders/{sharedFolderId}Get a shared folder

Manage drive permissions {#manage-sharedrive-permission}

You can manage collaborative drive permissions using the following API operations.

HTTP requestDescription
GET /sharedrives/{sharedriveId}/permissionsGet collaborative drive permissions
POST /sharedrives/{sharedriveId}/permissionsCreate a collaborative drive permission
GET /sharedrives/{sharedriveId}/permissions/{permissionId}Get a collaborative drive permission
PATCH /sharedrives/{sharedriveId}/permissions/{permissionId}Update a collaborative drive permission
DELETE /sharedrives/{sharedriveId}/permissions/{permissionId}Remove a collaborative drive permission
DELETE /sharedrives/{sharedriveId}/permissionsRemove all collaborative drive permissions
POST /sharedrives/{sharedriveId}/permissions/enableCollaborative drive - Enable access permission
POST /sharedrives/{sharedriveId}/permissions/disableCollaborative drive - Disable access permission

Manage the root folder {#manage-rootfolder}

You can upload files to the root folder, get files, and create a folder using the following API operations.

Manage my drive root folder {#manage-mydrive-rootfolder}

You can manage the root folder of my drive using the following API operations.

HTTP requestDescription
POST /users/{userId}/drive/filesMy drive - Create a file upload URL (root)
GET /users/{userId}/drive/filesMy drive - Get root files
POST /users/{userId}/drive/files/createfolderMy drive - Create a folder in the root

Manage collaborative drive root folder {#manage-sharedrive-rootfolder}

You can manage the root folder of a collaborative drive using the following API operations.

HTTP requestDescription
POST /sharedrives/{sharedriveId}/filesCollaborative drive - Create a file upload URL (root)
GET /sharedrives/{sharedriveId}/filesCollaborative drive - Get root files
POST /sharedrives/{sharedriveId}/files/createfolderCollaborative drive - Create a folder in the root

Manage team/group folder root folder {#manage-groupfolder-rootfolder}

You can manage the root folder of a team/group folder using the following API operations.

HTTP requestDescription
POST /groups/{groupId}/folder/filesTeam/group folder - Create a file upload URL (root)
GET /groups/{groupId}/folder/filesTeam/group folder - Get root files
POST /groups/{groupId}/folder/files/createfolderTeam/group folder - Create a folder in the root

Manage shared folder root folder {#manage-sharedfolder-rootfolder}

You can manage the root folder of a folder shared with me using the following API operations.

HTTP requestDescription
POST /users/{userId}/drive/sharedfolders/{sharedFolderId}/filesShared folder - Create a root file upload URL (root)
GET /users/{userId}/drive/sharedfolders/{sharedFolderId}/filesShared folder - Get root files
POST /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/createfolderShared folder - Create a folder in the root

Manage files and folders {#manage-file-folder}

For how to upload or download a file, see Upload or Download Files. You can lock or unlock a file to restrict editing.

Manage my drive files and folders {#manage-mydrive-file-folder}

You can manage files and folders in my drive using the following API operations.

HTTP requestDescription
GET /users/{userId}/drive/files/{fileId}/childrenMy drive - Get files
GET /users/{userId}/drive/files/{fileId}My drive - Get file properties
DELETE /users/{userId}/drive/files/{fileId}My drive - Delete a file
POST /users/{userId}/drive/files/{fileId}/createfolderMy drive - Create a folder
POST /users/{userId}/drive/files/{fileId}/copyMy drive - Copy a file
POST /users/{userId}/drive/files/{fileId}/renameMy drive - Rename a file
POST /users/{userId}/drive/files/{fileId}/moveMy drive - Move a file
POST /users/{userId}/drive/files/{fileId}/protectMy drive - Mark a file as Important
POST /users/{userId}/drive/files/{fileId}/unprotectMy drive - Unmark an important file
POST /users/{userId}/drive/files/{fileId}/lockMy drive - Lock a file
POST /users/{userId}/drive/files/{fileId}/unlockMy drive - Unlock a file
POST /users/{userId}/drive/files/{fileId}My drive - Create a file upload URL
GET /users/{userId}/drive/files/{fileId}/downloadMy drive - Download a file

Manage collaborative drive files and folders {#manage-sharedrive-file-folder}

Manage files and folders in a collaborative drive using the following API operations.

HTTP requestDescription
GET /sharedrives/{sharedriveId}/files/{fileId}/childrenCollaborative drive - Get files
GET /sharedrives/{sharedriveId}/files/{fileId}Collaborative drive - Get file properties
DELETE /sharedrives/{sharedriveId}/files/{fileId}Collaborative drive - Delete a file
POST /sharedrives/{sharedriveId}/files/{fileId}/createfolderCollaborative drive - Create a folder
POST /sharedrives/{sharedriveId}/files/{fileId}/copyCollaborative drive - Copy a file
POST /sharedrives/{sharedriveId}/files/{fileId}/renameCollaborative drive - Rename a file
POST /sharedrives/{sharedriveId}/files/{fileId}/moveCollaborative drive - Move a file
POST /sharedrives/{sharedriveId}/files/{fileId}/protectCollaborative drive - Mark a file as Important
POST /sharedrives/{sharedriveId}/files/{fileId}/unprotectCollaborative drive - Unmark an important file
POST /sharedrives/{sharedriveId}/files/{fileId}/lockCollaborative drive - Lock a file
POST /sharedrives/{sharedriveId}/files/{fileId}/unlockCollaborative drive - Unlock a file
POST /sharedrives/{sharedriveId}/files/{fileId}Collaborative drive - Create a file upload URL
GET /sharedrives/{sharedriveId}/files/{fileId}/downloadCollaborative drive - Download a file

Manage team/group files and folders {#manage-groupfolder-file-folder}

You can manage files and folders in a team/group folder using the following API operations.

HTTP requestDescription
GET /groups/{groupId}/folder/files/{fileId}/childrenTeam/group - Get files
GET /groups/{groupId}/folder/files/{fileId}Team/group - Get file properties
DELETE /groups/{groupId}/folder/files/{fileId}Team/group - Delete a file
POST /groups/{groupId}/folder/files/{fileId}/createfolderTeam/group - Create a folder
POST /groups/{groupId}/folder/files/{fileId}/copyTeam/group - Copy a file
POST /groups/{groupId}/folder/files/{fileId}/renameTeam/group - Rename a file
POST /groups/{groupId}/folder/files/{fileId}/moveTeam/group - Move a file
POST /groups/{groupId}/folder/files/{fileId}/protectTeam/group - Mark a file as Important
POST /groups/{groupId}/folder/files/{fileId}/unprotectTeam/group - Unmark an important file
POST /groups/{groupId}/folder/files/{fileId}/lockTeam/group - Lock a file
POST /groups/{groupId}/folder/files/{fileId}/unlockTeam/group - Unlock a file
POST /groups/{groupId}/folder/files/{fileId}Team/group - Create a file upload URL
GET /groups/{groupId}/folder/files/{fileId}/downloadTeam/group - Download a file

Manage shared folder files and folders {#manage-sharedfolder-file-folder}

You can manage files and folders in a folder shared with me using the following API operations.

HTTP requestDescription
GET /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/childrenShared folder - Get files
GET /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}Shared folder - Get file properties
DELETE /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}Shared folder - Delete a file
POST /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/createfolderShared folder - Create a folder
POST /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/copyShared folder - Copy a file
POST /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/renameShared folder - Rename a file
POST /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/moveShared folder - Move a file
POST /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/protectShared folder - Mark a file as Important
POST /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/unprotectShared folder - Unmark an important file
POST /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/lockShared folder - Lock a file
POST /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/unlockShared folder - Unlock a file
POST /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}Shared folder - Create an upload URL
GET /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/downloadShared folder - Download a file

Manage folder access permissions {#manage-folder-permission}

For collaborative drives and team/group folder, API operations for managing folder access permissions are available.
A folder basically inherits the permissions of its parent folder, but you can use the Enable folder access permissions API operation to set different permissions than the parent folder.
You can grant a member, team, and group access permissions using the Create a folder access permission API operation. The access permissions include READ and WRITE permissions.

You can get users who can access a folder and their permissions using the Get folder access permissions API operation. The permission of a user (member, team, and group) is assigned a permissionId.
You can remove a user's permission using the Remove a folder access permission API operation with the permissionId specified, or you can change it using the Update a folder access permission API operation.

To inherit the permissions of the parent folder, use the Disable folder access permission API operation.
You can allow only the collaborative drive or team/group master to access the folder using the Remove a folder access permission API operation.

Note

  • Note that you cannot manage my drive permissions using the API.

Manage collaborative drive folder access permissions {#manage-sharedrive-folder-permission}

You can manage folder access permissions of a collaborative drive using the following API operations.

HTTP requestDescription
POST /sharedrives/{sharedriveId}/files/{fileId}/permissionsCollaborative drive - Create a folder access permission
GET /sharedrives/{sharedriveId}/files/{fileId}/permissionsCollaborative drive - Get folder access permissions
GET /sharedrives/{sharedriveId}/files/{fileId}/permissions/{permissionId}Collaborative drive - Get a folder access permission
PATCH /sharedrives/{sharedriveId}/files/{fileId}/permissions/{permissionId}Collaborative drive - Update a folder access permission
DELETE /sharedrives/{sharedriveId}/files/{fileId}/permissions/{permissionId}Collaborative drive - Remove a folder access permission
DELETE /sharedrives/{sharedriveId}/files/{fileId}/permissionsCollaborative drive - Remove all folder access permissions
POST /sharedrives/{sharedriveId}/files/{fileId}/permissions/enableCollaborative drive - Enable folder access permissions
POST /sharedrives/{sharedriveId}/files/{fileId}/permissions/disableCollaborative drive - Disable folder access permissions

Manage team/group folder access permissions {#manage-groupfolder-folder-permission}

You can manage folder access permissions of a team/group using the following API operations.

HTTP requestDescription
POST /groups/{groupId}/folder/files/{fileId}/permissionsTeam/group - Create a folder access permission
GET /groups/{groupId}/folder/files/{fileId}/permissionsTeam/group - Get folder access permissions
GET /groups/{groupId}/folder/files/{fileId}/permissions/{permissionId}Team/group - Get a folder access permission
PATCH /groups/{groupId}/folder/files/{fileId}/permissions/{permissionId}Team/group - Update a folder access permission
DELETE /groups/{groupId}/folder/files/{fileId}/permissions/{permissionId}Team/group - Remove a folder access permission
DELETE /groups/{groupId}/folder/files/{fileId}/permissionsTeam/group - Remove all folder access permissions
POST /groups/{groupId}/folder/files/{fileId}/permissions/enableTeam/group - Enable folder access permissions
POST /groups/{groupId}/folder/files/{fileId}/permissions/disableTeam/group - Disable folder access permissions

Manage shared folder permissions {#manage-sharedfolder-folder-permission}

You can manage access permissions of a folder shared with me using the following API operation.

HTTP requestDescription
POST /users/{userId}/drive/sharedfolders/{sharedFolderId}/membersShared folder - Get members

Manage file revisions {#manage-version}

You can use file revisions to check whether a file is updated or overwritten, and restore or download a previous file revision.

Manage revisions in my drive {#manage-mydrive-version}

You can manage file revisions in my drive using the following API operations.

HTTP requestDescription
GET /users/{userId}/drive/files/{fileId}/revisionsMy drive - Get file revisions
GET /users/{userId}/drive/files/{fileId}/revisions/{revisionId}My drive - Get file revision properties
POST /users/{userId}/drive/files/{fileId}/revisions/{revisionId}/restoreMy drive - Restore to a file revision
GET /users/{userId}/drive/files/{fileId}/revisions/{revisionId}/downloadMy drive - Download a file revision

Manage revisions in a collaborative drive {#manage-sharedrive-version}

You can manage file revisions in a collaborative drive using the following API operations.

HTTP requestDescription
GET /sharedrives/{sharedriveId}/files/{fileId}/revisionsCollaborative drive - Get file revisions
GET /sharedrives/{sharedriveId}/files/{fileId}/revisions/{revisionId}Collaborative drive - Get file revision properties
POST /sharedrives/{sharedriveId}/files/{fileId}/revisions/{revisionId}/restoreCollaborative drive - Restore to a file revision
GET /sharedrives/{sharedriveId}/files/{fileId}/revisions/{revisionId}/downloadCollaborative drive - Download a file revision

Manage versions in a team/group folder {#manage-groupfolder-version}

You can manage file revisions in a team/group folder using the following API operations.

HTTP requestDescription
GET /groups/{groupId}/folder/files/{fileId}/revisionsTeam/group - Get file revisions
GET /groups/{groupId}/folder/files/{fileId}/revisions/{revisionId}Team/group - Get file revision properties
POST /groups/{groupId}/folder/files/{fileId}/revisions/{revisionId}/restoreTeam/group - Restore to a file revision
GET /groups/{groupId}/folder/files/{fileId}/revisions/{revisionId}/downloadTeam/group - Download a file revision

Manage file revisions in a shared folder {#manage-sharedfolder-version}

You can manage file revisions in a folder shared with me using the following API operations.

HTTP requestDescription
GET /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/revisionsShared folder - Get file revisions
GET /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/revisions/{revisionId}Shared folder - Get file revision properties
POST /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/revisions/{revisionId}/restoreShared folder - Restore to a file revision
GET /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/revisions/{revisionId}/downloadShared folder - Download a file revision

Manage link sharing {#manage-link}

You can share a file or folder through a link.

Manage link sharing in my drive {#manage-link-drive}

HTTP requestDescription
GET /users/{userId}/drive/link-settingMy drive - Get link settings
GET /users/{userId}/drive/files/{fileId}/linkMy drive - Get file link properties
POST /users/{userId}/drive/files/{fileId}/linkMy drive - Create a file link
PATCH /users/{userId}/drive/files/{fileId}/linkMy drive - Update a file link
DELETE /users/{userId}/drive/files/{fileId}/linkMy drive - Delete a file link

Manage link sharing in a collaborative drive {#manage-link-sharedrive}

HTTP requestDescription
GET /sharedrives/{sharedriveId}/link-settingCollaborative drive - Get link settings
GET /sharedrives/{sharedriveId}/files/{fileId}/linkCollaborative drive - Get file link properties
POST /sharedrives/{sharedriveId}/files/{fileId}/linkCollaborative drive - Create a file link
PATCH /sharedrives/{sharedriveId}/files/{fileId}/linkCollaborative drive - Update a file link
DELETE /sharedrives/{sharedriveId}/files/{fileId}/linkCollaborative drive - Delete a file link

Manage link sharing in a team/group folder {#manage-link-group}

HTTP requestDescription
GET /groups/{groupId}/folder/link-settingTeam/group folder - Get link settings
GET /groups/{groupId}/folder/files/{fileId}/linkTeam/group folder - Get file link properties
POST /groups/{groupId}/folder/files/{fileId}/linkTeam/group folder - Create a file link
PATCH /groups/{groupId}/folder/files/{fileId}/linkTeam/group folder - Update a file link
DELETE /groups/{groupId}/folder/files/{fileId}/linkTeam/group folder - Delete a file link

Manage link sharing in a shared folder {#manage-link-sharedfolder}

HTTP requestDescription
GET /users/{userId}/drive/sharedfolders/{sharedFolderId}/link-settingShared folder - Get link settings
GET /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/linkShared folder - Get file link properties
POST /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/linkShared folder - Create a file link
PATCH /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/linkShared folder - Update a file link
DELETE /users/{userId}/drive/sharedfolders/{sharedFolderId}/files/{fileId}/linkShared folder - Delete a file link

Manage trashed files {#manage-trashfile}

A file deleted by a user is moved to the trash and then permanently deleted after the retention period specified by the administrator.
You can delete or restore files in the trash using the following API operations.

Manage trashed files in my drive {#manage-mydrive-trashfile}

You can manage trashed files in my drive using the following API operations.

HTTP requestDescription
GET /users/{userId}/drive/trash-filesMy drive - Get trashed files
POST /users/{userId}/drive/trash-files/{trashFileId}/restoreMy drive - Restore a trashed file
DELETE /users/{userId}/drive/trash-files/{trashFileId}My drive - Delete a trashed file

Manage trashed files in a collaborative drive {#manage-sharedrive-trashfile}

You can manage trashed files in a collaborative drive using the following API operations.

HTTP requestDescription
GET /sharedrives/{sharedriveId}/trash-filesCollaborative drive - Get trashed files
POST /sharedrives/{sharedriveId}/trash-files/{trashFileId}/restoreCollaborative drive - Restore a trashed file
DELETE /sharedrives/{sharedriveId}/trash-files/{trashFileId}Collaborative drive - Delete a trashed file

Manage trashed files in a team/group folder {#manage-groupfolder-trashfile}

You can manage trashed files in a team/group folder using the following API operations.

HTTP requestDescription
GET /groups/{groupId}/folder/trash-filesTeam/group - Get trashed files
POST /groups/{groupId}/folder/trash-files/{trashFileId}/restoreTeam/group - Restore a trashed file
DELETE /groups/{groupId}/folder/trash-files/{trashFileId}Team/group - Delete a trashed file