Google Drive actions
Reference for the Google Drive actions: the Google Drive connection, each action id, download, upload and sharing rules, outputs and an example.
The Google Drive block reads, writes, creates, organises and shares files and folders in Google Drive, including shared drives. For the plain-language guide, see Google Drive.
When to use it
Use it to read a document that a team keeps in Drive, to save a report or export into a folder, or to share a file with someone. There is no Google Drive trigger; for a sync, run on a schedule with getChangesStartPageToken and listChanges.
Connection
- Provider id:
google-drive. Google OAuth through Nango, scopehttps://www.googleapis.com/auth/drive. - The block sees only what the Google user behind the connection can see. Shared drive actions need a Google Workspace account.
- Pin an account with
config.connection. Without it, the step uses the company's default Google Drive connection.
Actions
| Action id | Studio label | What it does |
|---|---|---|
google-drive.copyFile | Copy File | Copy a file, optionally renamed and into another folder. Folders cannot be copied. |
google-drive.createComment | Create Comment | Add a comment to a file. |
google-drive.createDrive | Create Shared Drive | Create a shared drive. Needs a Google Workspace account allowed to create shared drives. |
google-drive.createFolder | Create Folder | Create a folder, in My Drive root unless a parent is set. |
google-drive.deleteComment | Delete Comment | Delete a comment from a file. |
google-drive.deleteDrive | Delete Shared Drive | Permanently delete a shared drive. It must be empty unless a domain admin sets allowItemDeletion. |
google-drive.deleteFile | Delete File | Permanently delete a file or folder (and a folder’s contents), skipping the trash. To trash instead, use Update File with trashed. |
google-drive.deletePermission | Delete Permission | Remove someone’s access to a file or folder. |
google-drive.emptyTrash | Empty Trash | Permanently delete every trashed file of the user, or of one shared drive. |
google-drive.findFile | Find File | Find files (not folders) whose name contains the given text, optionally of one MIME type. |
google-drive.findFolder | Find Folder | Find folders whose name contains the given text. |
google-drive.getAbout | Get Drive Info | Get the connected user and their storage quota. |
google-drive.getChangesStartPageToken | Get Changes Start Token | Get the token that marks now; pass it to List Changes later to get what changed since. |
google-drive.getComment | Get Comment | Get a comment on a file. |
google-drive.getDrive | Get Shared Drive | Get a shared drive’s metadata. |
google-drive.getFile | Get File | Get a file or folder’s metadata. |
google-drive.getPermission | Get Permission | Get one permission on a file or folder. |
google-drive.getRevision | Get Revision | Get one revision’s metadata. |
google-drive.hideDrive | Hide Shared Drive | Hide a shared drive from the default view. |
google-drive.listChanges | List Changes | List one page of changes since a page token. Keep calling with nextPageToken; the last page returns newStartPageToken for the next run. |
google-drive.listComments | List Comments | List one page of a file’s comments. Page with nextPageToken. |
google-drive.listDrives | List Shared Drives | List one page of the shared drives the user can see. Page with nextPageToken. |
google-drive.listFiles | List Files | List one page of files and folders, e.g. the items in a folder. Page with nextPageToken. |
google-drive.listPermissions | List Permissions | List who a file or folder is shared with. Page with nextPageToken. |
google-drive.shareFile | Share File | Share a file or folder by adding a permission for a user, group, domain, or anyone with the link. Google emails users and groups unless sendNotificationEmail is false. |
google-drive.unhideDrive | Unhide Shared Drive | Show a hidden shared drive in the default view again. |
google-drive.updateComment | Update Comment | Change a comment’s text. |
google-drive.updateDrive | Update Shared Drive | Rename a shared drive or change its restrictions. |
google-drive.updateFile | Update File | Rename a file or folder, change its description, star it, or move it to or from the trash. |
google-drive.updatePermission | Update Permission | Change a permission’s role or expiry. |
google-drive.uploadFile | Upload File | Create a file from text or base64 content (up to 5 MiB), optionally converted to a Google format. |
google-drive.updateFileContent | Update File Content | Replace a file’s content, keeping its ID, sharing and history. |
google-drive.downloadFile | Download File | Download a file as base64 (up to 3 MiB), or save it to workspace files with persistToFolder (up to 96 MiB). Google Docs, Sheets and Slides are exported. |
google-drive.moveFile | Move File | Move a file or folder into another folder. |
Settings
| Field | Studio label | Type | Used by | Required for |
|---|---|---|---|---|
connection | Google Drive Account | string (connection id) | All | Optional. Without it the step uses the company default connection for this system |
fileId | File Id | string | copyFile, createComment, deleteComment, deleteFile, deletePermission, getComment, getFile, getPermission, getRevision, listComments, listPermissions, shareFile, updateComment, updateFile, updatePermission, updateFileContent, downloadFile, moveFile | copyFile, createComment, deleteComment, deleteFile, deletePermission, getComment, getFile, getPermission, getRevision, listComments, listPermissions, shareFile, updateComment, updateFile, updatePermission, updateFileContent, downloadFile, moveFile |
name | Name | string | copyFile, createDrive, createFolder, findFile, findFolder, updateDrive, updateFile, uploadFile, updateFileContent | createDrive, createFolder, uploadFile |
parentId | Parent Id | string | copyFile, createFolder, uploadFile | |
content | Content | string | createComment, updateComment, uploadFile, updateFileContent | createComment, updateComment |
requestId | Request Id | string | createDrive | |
description | Description | string | createFolder, updateFile, uploadFile | |
commentId | Comment Id | string | deleteComment, getComment, updateComment | deleteComment, getComment, updateComment |
driveId | Drive Id | string | deleteDrive, emptyTrash, findFile, findFolder, getChangesStartPageToken, getDrive, hideDrive, listChanges, listFiles, unhideDrive, updateDrive | deleteDrive, getDrive, hideDrive, unhideDrive, updateDrive |
allowItemDeletion | Allow Item Deletion | boolean | deleteDrive | |
useDomainAdminAccess | Use Domain Admin Access | boolean | deleteDrive, getDrive, listDrives, updateDrive | |
permissionId | Permission Id | string | deletePermission, getPermission, updatePermission | deletePermission, getPermission, updatePermission |
mimeType | Mime Type | string | findFile | |
folderId | Folder Id | string | findFile, findFolder, listFiles, moveFile | moveFile |
query | Query | string | findFile, findFolder, listDrives, listFiles | |
includeTrashed | Include Trashed | boolean | findFile, findFolder, listFiles | |
orderBy | Order By | string | findFile, findFolder, listFiles | |
pageSize | Page Size | number | findFile, findFolder, listChanges, listComments, listDrives, listFiles, listPermissions | |
pageToken | Page Token | string | findFile, findFolder, listChanges, listComments, listDrives, listFiles, listPermissions | listChanges |
includeDeleted | Include Deleted | boolean | getComment, listComments | |
revisionId | Revision Id | string | getRevision | getRevision |
includeRemoved | Include Removed | boolean | listChanges | |
startModifiedTime | Start Modified Time | string | listComments | |
type | Type | string | shareFile | shareFile |
role | Role | string | shareFile, updatePermission | shareFile |
emailAddress | Email Address | string | shareFile | |
domain | Domain | string | shareFile | |
allowFileDiscovery | Allow File Discovery | boolean | shareFile | |
expirationTime | Expiration Time | string | shareFile, updatePermission | |
sendNotificationEmail | Send Notification Email | boolean | shareFile | |
emailMessage | Email Message | string | shareFile | |
transferOwnership | Transfer Ownership | boolean | shareFile, updatePermission | |
adminManagedRestrictions | Admin Managed Restrictions | boolean | updateDrive | |
copyRequiresWriterPermission | Copy Requires Writer Permission | boolean | updateDrive | |
domainUsersOnly | Domain Users Only | boolean | updateDrive | |
driveMembersOnly | Drive Members Only | boolean | updateDrive | |
starred | Starred | boolean | updateFile | |
trashed | Trashed | boolean | updateFile | |
contentBase64 | Content Base64 | string | uploadFile, updateFileContent | |
contentType | Content Type | string | uploadFile, updateFileContent | |
convertToMimeType | Convert To Mime Type | string | uploadFile | |
exportMimeType | Export Mime Type | string | downloadFile | |
persistToFolder | Persist To Folder | string | downloadFile |
The folder id root is the user's My Drive.
Find and list
listFiles,findFileandfindFolderleave out trashed items unlessincludeTrashedis true, and include shared drives.folderIdkeeps only items directly inside that folder.driveIdsearches one shared drive.queryis a Drive search clause added withand.findFileandfindFoldermatch names that containname.- Every list returns
nextPageToken, which isnullon the last page. Pass it aspageTokenfor the next page.
Download File
- Without
persistToFolder, the file must be 3 MiB or smaller. It comes back as base64contentwithname,sizeandmimeType, plustextfor text and JSON files (nullotherwise). - With
persistToFolder(a folder path in Files), the file can be up to 96 MiB. It is saved as<fileId>-<name>and the step returnsworkspaceFileId,filePathandpersisted: truewith no content. PassworkspaceFileIdasfileIdto the PDF block. - Google Docs, Sheets, Slides and Drawings are exported: as
text/plain,text/csv,application/pdfandimage/pngby default. SetexportMimeTypefor another format, such asapplication/pdffor a Doc. Google limits exports to 10 MB. Other Google types, such as Forms, needexportMimeType.
Upload File and Update File Content
- Set exactly one of
content(text) orcontentBase64. The content can be up to 5 MiB. contentTypedefaults totext/plainforcontentandapplication/octet-streamforcontentBase64.uploadFilecreates the file in My Drive unlessparentIdis set. SetconvertToMimeTypetoapplication/vnd.google-apps.documentorapplication/vnd.google-apps.spreadsheetto make a Google Doc or Sheet.updateFileContentkeeps the file's ID, sharing and history.
Sharing
shareFileneedstype(user,group,domainoranyone) androle(reader,commenter,writer,fileOrganizer,organizerorowner).userandgroupneedemailAddress;domainneedsdomain.ownerneedstransferOwnership: true.- Google emails the user or group unless
sendNotificationEmailis false, so the step is marked as one that reaches people outside the workspace.
Delete and trash
deleteFiledeletes permanently and skips the trash. To move an item to the trash, useupdateFilewithtrashed: true.emptyTrashpermanently deletes everything in the user's trash, or in a shared drive's trash withdriveId.deleteDriveneeds an empty shared drive unless a domain admin setsallowItemDeletionanduseDomainAdminAccess.
Changes
Call getChangesStartPageToken once and save startPageToken. Each run, call listChanges with the saved token, follow nextPageToken until it is null, and save newStartPageToken for the next run.
Output
- File and folder actions return the Drive file with
id,name,mimeType,size,parents,driveId,description,starred,trashed,createdTime,modifiedTimeandwebViewLink. - List actions return
files,comments,permissions,drivesorchanges, withnextPageToken. - Delete actions return the id and
deleted: true;emptyTrashreturnsemptied: true. - The other actions return the Drive API object.
Read fields with {{steps.<stepId>.<path>}}, for example {{steps.find_report.files.0.id}}.
Example
Find the newest month-end report PDF in a folder, save it to Files, and share it with the controller without an email.
{
"name": "Collect the month-end report",
"trigger": { "type": "api" },
"steps": [
{
"id": "find_report",
"type": "action",
"name": "Find the report",
"action": "google-drive.findFile",
"config": {
"name": "Month-end report",
"mimeType": "application/pdf",
"folderId": "1AbCdEfGhIjKlMnOp",
"orderBy": "modifiedTime desc",
"pageSize": 1
}
},
{
"id": "save_report",
"type": "action",
"name": "Save the report to Files",
"action": "google-drive.downloadFile",
"config": {
"fileId": "{{steps.find_report.files.0.id}}",
"persistToFolder": "month-end"
}
},
{
"id": "share_report",
"type": "action",
"name": "Share with the controller",
"action": "google-drive.shareFile",
"config": {
"fileId": "{{steps.find_report.files.0.id}}",
"type": "user",
"role": "reader",
"emailAddress": "controller@example.com",
"sendNotificationEmail": false
}
}
]
}Live catalog
GET /api/v1/blocks/google-drivereturns the actions and fields.GET /api/v1/blocks/google-drive/actions/<operation>/examplesreturns stored examples where they exist.
Errors and limits
downloadFilewaits up to 5 minutes for the file content.- A missing required field or a malformed ID fails the step before Google Drive is called. Google errors fail the step with Google's message.
Email actions
Reference for the Send Email, Gmail and Outlook actions: step types, connections, each action id, the fields each executor reads, outputs and an example.
Google Sheets actions
Reference for the Google Sheets actions: the Google connection, each action id, A1 ranges, value input options, row upserts, outputs and an example.
Loopfour