Skip to main content
Roberty Studio
RPAGoogle

Google Drive

Google Drive

The Google Drive module is responsible for actions that integrate the Google Drive tool. Its methods can be accessed as in the example below:

js
const driveConnection = await API.Google.Drive.Connection["v1_0_0"]({
connectionId: "id-da-conexao-configurada-no-workspace",
});
info

The Connection action returns an authenticated Google Drive connection instance directly (not a text ID). This instance must be stored in a variable — such as driveConnection in the examples below — and reused in the driveConnection parameter of every other action of this module.

Items shared with me​

The file and folder methods accept the sharedWithMe parameter to work with items someone else shared with the connected account (the "Shared with me" section of Google Drive). With sharedWithMe: true, the first part of the path is looked up in "Shared with me" and the rest is walked normally from there; the drive parameter is not used for that lookup.

js
// files shared directly with the account
const shared = await API.Google.Drive.Files.List["v1_0_0"]({
driveConnection: driveConnection,
path: "/",
sharedWithMe: true,
});

// file inside a shared folder
await API.Google.Drive.Files.Download["v1_0_0"]({
driveConnection: driveConnection,
remotePath: "/Client folder/report.pdf",
localPath: "C:\\Downloads\\report.pdf",
sharedWithMe: true,
});

In Files.Move and Folders.Move, newParentSharedWithMe does the same for the destination path, so items can move from My Drive into a shared folder and back. Methods that change a shared item (upload, rename, move, trash) depend on the edit permission the owner gave the account; without it, the run stops with an error.

Methods​

Connection​

Method responsible for establishing a connection with Google Drive from a connection configured in the workspace.

js
const driveConnection = await API.Google.Drive.Connection["v1_0_0"]({
connectionId: "id-da-conexao-configurada-no-workspace",
});

Required parameters​

  • connectionId:String - expects the ID of the Google connection configured in the workspace (Workspace → Connections).

Optional parameters​

This method has no optional parameters.

Return​

It returns the authenticated Google Drive connection instance, which must be stored in a variable (e.g. driveConnection) and reused as the driveConnection parameter in the other methods of this module.

EmptyTrash​

Method responsible for emptying the trash of a specific drive or of the default "My Drive", permanently deleting every item it contains.

js
await API.Google.Drive.EmptyTrash["v1_0_0"]({
driveConnection: driveConnection,
name: "",
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.

Optional parameters​

  • name:String - expects the name of the drive whose trash will be emptied. If it is not provided, it empties the trash of the "My Drive" of the authenticated account.

Return​

This method has no return.

Drives.List​

Method responsible for listing every drive available to the authenticated account, including shared drives.

js
const drivesList = await API.Google.Drive.Drives.List["v1_0_0"]({
driveConnection: driveConnection,
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.

Optional parameters​

This method has no optional parameters.

Return​

js
actions.drivesList.drives // lista de drives disponíveis, cada item contendo id e name (Array)

Drives.GetByName​

Method responsible for getting the information of a specific drive by its name.

js
const drive = await API.Google.Drive.Drives.GetByName["v1_0_0"]({
driveConnection: driveConnection,
name: "Drive Compartilhado",
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.
  • name:String - expects the exact name of the drive to be located.

Optional parameters​

This method has no optional parameters.

Return​

js
actions.drive.id // identificador único do drive (String)
actions.drive.name // nome do drive (String)

If no drive is found with the name provided, the execution is interrupted with an error.

Files.List​

Method responsible for listing the files in a specific folder of Google Drive.

js
const filesList = await API.Google.Drive.Files.List["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
path: "/Documentos",
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.
  • path:String - expects the path of the folder whose files will be listed. Use / to list the root of the drive.

Optional parameters​

  • drive:String - expects the name of the drive to be accessed. Default: "root" (My Drive).
  • sharedWithMe:Boolean - when true, the first part of path is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.

Return​

js
actions.filesList.files // lista de arquivos encontrados, cada item contendo id, name e extension (Array)

Files.GetByName​

Method responsible for getting the detailed information of a file from its path in Google Drive.

js
const file = await API.Google.Drive.Files.GetByName["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
path: "/Documentos/relatorio.pdf",
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.
  • path:String - expects the full path of the file, including the name and extension.

Optional parameters​

  • drive:String - expects the name of the drive to be accessed. Default: "root" (My Drive).
  • sharedWithMe:Boolean - when true, the first part of path is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.

Return​

js
actions.file.id // identificador único do arquivo (String)
actions.file.name // nome do arquivo (String)
actions.file.extension // extensão do arquivo (String)
actions.file.createdTime // data de criação (String)
actions.file.modifiedTime // data da última modificação (String)
actions.file.shared // indica se o arquivo está compartilhado (Boolean)

If the file is not found, the execution is interrupted with an error.

Files.Exists​

Method responsible for checking whether a file exists at a specific path of Google Drive.

js
const fileExists = await API.Google.Drive.Files.Exists["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
path: "/Documentos/relatorio.pdf",
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.
  • path:String - expects the full path of the file to check, including the name and extension.

Optional parameters​

  • drive:String - expects the name of the drive to be accessed. Default: "root" (My Drive).
  • sharedWithMe:Boolean - when true, the first part of path is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.

Return​

js
actions.fileExists.exists // verdadeiro se o arquivo existe, falso caso contrário (Boolean)

This action never interrupts the execution for not finding the file — use the exists return for conditional flow control.

Files.Download​

Method responsible for downloading a file from Google Drive to a local path.

js
const download = await API.Google.Drive.Files.Download["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
remotePath: "/Documentos/relatorio.pdf",
localPath: "C:\\Downloads\\relatorio.pdf",
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.
  • localPath:String - expects the local path where the file will be saved, including the file name.

Optional parameters​

  • remotePath:String - expects the full path of the file in Google Drive, including the name and extension.
  • drive:String - expects the name of the origin drive. Default: "root" (My Drive).
  • sharedWithMe:Boolean - when true, the first part of remotePath is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.
  • fileId:String - expects the ID of the file in Google Drive (for example, the id returned by Files.GetByName or Files.List). When provided, the file is located directly by its ID and remotePath, drive and sharedWithMe are not used to locate it.

You must provide remotePath or fileId; if both are provided, fileId takes precedence.

Return​

js
actions.download.downloadPath // caminho local completo onde o arquivo foi salvo (String)

Files.Upload​

Method responsible for uploading a local file to a specific path in Google Drive.

js
const upload = await API.Google.Drive.Files.Upload["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
remotePath: "/Documentos/relatorio.pdf",
localPath: "C:\\Relatorios\\relatorio.pdf",
createFoldersIfNecessary: false,
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.
  • remotePath:String - expects the full destination path in Google Drive, including the file name and extension.
  • localPath:String - expects the full path of the local file to be sent.

Optional parameters​

  • drive:String - expects the name of the destination drive. Default: "root" (My Drive).
  • createFoldersIfNecessary:Boolean - when it is true, it automatically creates the destination path folders that do not exist yet. If it is not provided and the destination path does not exist, the execution is interrupted with an error.
  • sharedWithMe:Boolean - when true, the first part of remotePath is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.

Return​

js
actions.upload.id // identificador único do arquivo criado no Google Drive (String)

Files.Rename​

Method responsible for renaming a file in Google Drive.

js
const rename = await API.Google.Drive.Files.Rename["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
path: "/Documentos/relatorio_antigo.pdf",
newName: "relatorio_2026.pdf",
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.
  • newName:String - expects the new name for the file, including the extension.

Optional parameters​

  • path:String - expects the full path of the file to be renamed, including the name and extension.
  • drive:String - expects the name of the drive to be accessed. Default: "root" (My Drive).
  • sharedWithMe:Boolean - when true, the first part of path is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.
  • fileId:String - expects the ID of the file in Google Drive (for example, the id returned by Files.GetByName or Files.List). When provided, the file is located directly by its ID and path, drive and sharedWithMe are not used to locate it.

You must provide path or fileId; if both are provided, fileId takes precedence.

Return​

js
actions.rename.name // novo nome do arquivo após a renomeação (String)

Files.Move​

Method responsible for moving a file to a new destination, which can be on a different drive.

js
const move = await API.Google.Drive.Files.Move["v1_0_0"]({
driveConnection: driveConnection,
originDrive: "",
destinationDrive: "",
path: "/Documentos/relatorio.pdf",
newParentPath: "/Arquivo/2026",
createFoldersIfNecessary: false,
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.

Optional parameters​

  • path:String - expects the full path of the file to be moved, including the name and extension.
  • newParentPath:String - expects the path of the destination folder.
  • originDrive:String - expects the name of the drive where the file currently is. Default: "root" (My Drive).
  • destinationDrive:String - expects the name of the drive the file will be moved to. Default: "root" (My Drive).
  • createFoldersIfNecessary:Boolean - when it is true, it automatically creates the destination path folders that do not exist yet. If it is not provided and the destination does not exist, the execution is interrupted with an error.
  • sharedWithMe:Boolean - when true, the first part of path is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.
  • newParentSharedWithMe:Boolean - when true, the first folder of newParentPath is looked up in "Shared with me". The path must include at least the shared folder. Default: false.
  • fileId:String - expects the ID of the file in Google Drive (for example, the id returned by Files.GetByName or Files.List). When provided, the file is located directly by its ID and path, originDrive and sharedWithMe are not used to locate it.
  • newParentId:String - expects the ID of the destination folder. When provided, the destination is located directly by its ID and newParentPath, destinationDrive, newParentSharedWithMe and createFoldersIfNecessary are not used.

You must provide path or fileId; if both are provided, fileId takes precedence. You must provide newParentPath or newParentId; if both are provided, newParentId takes precedence.

Return​

js
actions.move.newParentId // identificador único da pasta pai de destino (String)

Files.Trash​

Method responsible for moving a file to the Google Drive trash.

js
await API.Google.Drive.Files.Trash["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
path: "/Documentos/relatorio_antigo.pdf",
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.

Optional parameters​

  • path:String - expects the full path of the file to be moved to the trash, including the name and extension.
  • drive:String - expects the name of the drive to be accessed. Default: "root" (My Drive).
  • sharedWithMe:Boolean - when true, the first part of path is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.
  • fileId:String - expects the ID of the file in Google Drive (for example, the id returned by Files.GetByName or Files.List). When provided, the file is located directly by its ID and path, drive and sharedWithMe are not used to locate it.

You must provide path or fileId; if both are provided, fileId takes precedence.

Return​

This method has no return. The file can be restored using the Files.RestoreFromTrash method, or deleted permanently with the EmptyTrash method.

Files.RestoreFromTrash​

Method responsible for restoring a file from the trash to its original location in Google Drive.

js
await API.Google.Drive.Files.RestoreFromTrash["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
path: "/Documentos/relatorio_antigo.pdf",
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.

Optional parameters​

  • drive:String - expects the name of the drive to be accessed. Default: "root" (My Drive).
  • path:String - expects the path the file had before it was moved to the trash, including the name and extension.
  • sharedWithMe:Boolean - when true, the first part of path is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.
  • fileId:String - expects the ID of the file in Google Drive (for example, the id returned by Files.GetByName or Files.List). When provided, the file is located directly by its ID and path, drive and sharedWithMe are not used to locate it.

You must provide path or fileId; if both are provided, fileId takes precedence.

Return​

This method has no return.

Folders.List​

Method responsible for listing the folders at a specific path of Google Drive.

js
const foldersList = await API.Google.Drive.Folders.List["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
path: "/Documentos",
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.
  • path:String - expects the path of the folder to be listed. Use / to list the root of the drive.

Optional parameters​

  • drive:String - expects the name of the drive to be accessed. Default: "root" (My Drive).
  • sharedWithMe:Boolean - when true, the first part of path is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.

Return​

js
actions.foldersList.folders // lista de pastas encontradas, cada item contendo id e name (Array)

Folders.GetByName​

Method responsible for getting the detailed information of a folder from its path in Google Drive.

js
const folder = await API.Google.Drive.Folders.GetByName["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
path: "/Documentos/Relatórios",
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.
  • path:String - expects the full path of the folder.

Optional parameters​

  • drive:String - expects the name of the drive to be accessed. Default: "root" (My Drive).
  • sharedWithMe:Boolean - when true, the first part of path is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.

Return​

js
actions.folder.id // identificador único da pasta (String)
actions.folder.name // nome da pasta (String)
actions.folder.createdTime // data de criação (String)
actions.folder.modifiedTime // data da última modificação (String)
actions.folder.shared // indica se a pasta está compartilhada (Boolean)

If the folder is not found, the execution is interrupted with an error.

Folders.Create​

Method responsible for creating a new folder at a specific path of Google Drive.

js
const folderCreated = await API.Google.Drive.Folders.Create["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
path: "/Documentos/Relatórios/2026",
recursive: false,
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.
  • path:String - expects the full path of the folder to be created, including the name.

Optional parameters​

  • drive:String - expects the name of the drive where the folder will be created. Default: "root" (My Drive).
  • recursive:Boolean - when it is true, it automatically creates every folder of the path that does not exist yet. If it is not provided and some folder of the path does not exist, the execution is interrupted with an error.
  • sharedWithMe:Boolean - when true, the first part of path is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.

Return​

js
actions.folderCreated.id // identificador único da pasta criada no Google Drive (String)

Folders.Exists​

Method responsible for checking whether a folder exists at a specific path of Google Drive.

js
const folderExists = await API.Google.Drive.Folders.Exists["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
path: "/Documentos/Relatórios",
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.
  • path:String - expects the full path of the folder to check.

Optional parameters​

  • drive:String - expects the name of the drive to be accessed. Default: "root" (My Drive).
  • sharedWithMe:Boolean - when true, the first part of path is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.

Return​

js
actions.folderExists.exists // verdadeiro se a pasta existe, falso caso contrário (Boolean)

This action never interrupts the execution for not finding the folder — use the exists return for conditional flow control.

Folders.Rename​

Method responsible for renaming a folder in Google Drive.

js
await API.Google.Drive.Folders.Rename["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
path: "/Documentos/Relatórios",
newName: "Relatórios Antigos",
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.
  • newName:String - expects the new name for the folder.

Optional parameters​

  • path:String - expects the full path of the folder to be renamed.
  • drive:String - expects the name of the drive to be accessed. Default: "root" (My Drive).
  • sharedWithMe:Boolean - when true, the first part of path is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.
  • folderId:String - expects the ID of the folder in Google Drive (for example, the id returned by Folders.GetByName or Folders.List). When provided, the folder is located directly by its ID and path and sharedWithMe are not used to locate it.

You must provide path or folderId; if both are provided, folderId takes precedence.

Return​

This method has no return.

Folders.Move​

Method responsible for moving a folder to a new destination inside Google Drive.

js
const folderMove = await API.Google.Drive.Folders.Move["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
path: "/Documentos/Relatórios",
newParentPath: "/Arquivo/2026",
createFoldersIfNecessary: false,
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.

Optional parameters​

  • path:String - expects the full path of the folder to be moved.
  • newParentPath:String - expects the path of the destination folder.
  • drive:String - expects the name of the drive to be accessed. Default: "root" (My Drive).
  • createFoldersIfNecessary:Boolean - when it is true, it automatically creates the destination path folders that do not exist yet. If it is not provided and the destination does not exist, the execution is interrupted with an error.
  • sharedWithMe:Boolean - when true, the first part of path is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.
  • newParentSharedWithMe:Boolean - when true, the first folder of newParentPath is looked up in "Shared with me". The path must include at least the shared folder. Default: false.
  • folderId:String - expects the ID of the folder in Google Drive (for example, the id returned by Folders.GetByName or Folders.List). When provided, the folder is located directly by its ID and path and sharedWithMe are not used to locate it.
  • newParentId:String - expects the ID of the destination folder. When provided, the destination is located directly by its ID and newParentPath, drive, newParentSharedWithMe and createFoldersIfNecessary are not used.

You must provide path or folderId; if both are provided, folderId takes precedence. You must provide newParentPath or newParentId; if both are provided, newParentId takes precedence.

Return​

js
actions.folderMove.newParentId // identificador único da pasta pai de destino (String)

Folders.Trash​

Method responsible for moving a folder to the Google Drive trash.

js
await API.Google.Drive.Folders.Trash["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
path: "/Documentos/Antigos",
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.

Optional parameters​

  • path:String - expects the full path of the folder to be moved to the trash.
  • drive:String - expects the name of the drive to be accessed. Default: "root" (My Drive).
  • sharedWithMe:Boolean - when true, the first part of path is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.
  • folderId:String - expects the ID of the folder in Google Drive (for example, the id returned by Folders.GetByName or Folders.List). When provided, the folder is located directly by its ID and path and sharedWithMe are not used to locate it.

You must provide path or folderId; if both are provided, folderId takes precedence.

Return​

This method has no return. The folder can be restored using the Folders.RestoreFromTrash method, or deleted permanently with the EmptyTrash method.

Folders.RestoreFromTrash​

Method responsible for restoring a folder from the trash to its original location in Google Drive.

js
await API.Google.Drive.Folders.RestoreFromTrash["v1_0_0"]({
driveConnection: driveConnection,
drive: "",
pathBeforeTrash: "/Documentos/Antigos",
});

Required parameters​

  • driveConnection:Object - expects the connection instance obtained by the Connection method.

Optional parameters​

  • pathBeforeTrash:String - expects the path the folder had before it was moved to the trash.
  • drive:String - expects the name of the drive to be accessed. Default: "root" (My Drive).
  • sharedWithMe:Boolean - when true, the first part of pathBeforeTrash is looked up in "Shared with me" instead of the given drive. See Items shared with me. Default: false.
  • folderId:String - expects the ID of the folder in Google Drive (for example, the id returned by Folders.GetByName or Folders.List). When provided, the folder is located directly by its ID and pathBeforeTrash and sharedWithMe are not used to locate it.

You must provide pathBeforeTrash or folderId; if both are provided, folderId takes precedence.

Return​

This method has no return.