> ## Documentation Index
> Fetch the complete documentation index at: https://explore.airia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Drive

> Upload, download, share, and organize Google Drive files and folders from inside an agent workflow.

Google Drive actions let an agent work with files and folders directly in a flow. An agent can upload, download, copy, share, list, and delete files, and create folders, then pass the results to later steps.

## Supported actions

| Group      | Actions                                     |
| ---------- | ------------------------------------------- |
| **File**   | Upload, Download, Copy, Share, List, Delete |
| **Folder** | Create                                      |

## Prerequisites

<AccordionGroup>
  <Accordion title="Create a Google credential" icon="key">
    Connect a **Google OAuth** credential in [Credential Management](/admin-hub/account_settings/credential-management), then select it on every Google Drive action. To set up the OAuth client, follow the [Google Cloud Console setup guide](/integrations/oauth-setup/google-cloud-console). These actions also support end user authentication, so a step can act on each user's own Drive.
  </Accordion>
</AccordionGroup>

## How to use these actions

* **Map text inputs from earlier steps.** Inputs such as **File Name**, **File ID**, and **Query** accept a value mapped from a previous step.
* **Selections and toggles take fixed values.** The **Role**, **Permission Type**, and **File Return Mode** selections, the **Include Trashed** and **Send Notification Email** toggles, and **Max Results** are entered directly rather than mapped from a previous step.
* **File content is base64 encoded.** Pass uploaded file content as a base64 encoded string in **File Content Base64**.
* **Leave a parent folder empty for the root.** When a parent folder input is empty, the file or folder is placed in the root of the Drive.
* **List filters with query syntax.** The List action filters with Google Drive query syntax, such as `name contains 'report'`.

## Actions

### File

#### Google Drive File Upload

Uploads a new file to Drive.

| Input                   | Required | Description                                                       |
| ----------------------- | -------- | ----------------------------------------------------------------- |
| **File Name**           | Yes      | The name of the file to create.                                   |
| **File Content Base64** | Yes      | The file content as a base64 encoded string.                      |
| **Parent Folder ID**    | No       | The folder to place the file in. Leave empty for the root folder. |
| **Content Type**        | No       | The MIME type of the file, such as `application/pdf`.             |

#### Google Drive File Download

Downloads a file from Drive.

| Input                | Required | Description                                                                                                       |
| -------------------- | -------- | ----------------------------------------------------------------------------------------------------------------- |
| **File ID**          | Yes      | The unique identifier of the file to download.                                                                    |
| **File Return Mode** | No       | How to return the file, either `Content` for a base64 string or `Url` for a download link. Defaults to `Content`. |

#### Google Drive File Copy

Copies an existing file.

| Input                | Required | Description                                                                   |
| -------------------- | -------- | ----------------------------------------------------------------------------- |
| **File ID**          | Yes      | The unique identifier of the file to copy.                                    |
| **New File Name**    | No       | The name for the copy. Defaults to the original name prefixed with "Copy of". |
| **Parent Folder ID** | No       | The folder to place the copy in. Defaults to the original file's folder.      |

#### Google Drive File Share

Shares a file with a person or creates a public link.

| Input                       | Required | Description                                                                                                               |
| --------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------- |
| **File ID**                 | Yes      | The unique identifier of the file to share.                                                                               |
| **Email Address**           | No       | The person to share with. Leave empty to create a public link.                                                            |
| **Role**                    | No       | The access level, one of `reader`, `commenter`, `writer`, `fileOrganizer`, `organizer`, or `owner`. Defaults to `reader`. |
| **Permission Type**         | No       | The kind of grantee, one of `user`, `group`, `domain`, or `anyone`. Defaults to `user`.                                   |
| **Send Notification Email** | No       | Whether to email the recipient about the share. Toggle, defaults to on.                                                   |
| **Email Message**           | No       | A custom message to include in the notification.                                                                          |

#### Google Drive File List

Lists files in Drive.

| Input               | Required | Description                                                              |
| ------------------- | -------- | ------------------------------------------------------------------------ |
| **Folder ID**       | No       | The folder to list files from. Leave empty for the root folder.          |
| **Query**           | No       | A filter in Google Drive query syntax, such as `name contains 'report'`. |
| **Max Results**     | No       | Maximum number of files to return, from 1 to 1000. Defaults to 100.      |
| **Include Trashed** | No       | Whether to include trashed files. Toggle, defaults to off.               |

#### Google Drive File Delete

Deletes a file from Drive.

| Input       | Required | Description                                  |
| ----------- | -------- | -------------------------------------------- |
| **File ID** | Yes      | The unique identifier of the file to delete. |

### Folder

#### Google Drive Folder Create

Creates a new folder.

| Input                | Required | Description                                                             |
| -------------------- | -------- | ----------------------------------------------------------------------- |
| **Folder Name**      | Yes      | The name of the folder to create.                                       |
| **Parent Folder ID** | No       | The folder to place the new folder in. Leave empty for the root folder. |

## Example

An agent that files a generated report into Drive and shares it:

<Steps>
  <Step title="Create a folder">
    A **Google Drive Folder Create** action makes a folder named for the reporting period and returns its ID.
  </Step>

  <Step title="Upload the report">
    A **Google Drive File Upload** action sets **File Name** and **File Content Base64** from the generated report, sets **Content Type** to `application/pdf`, and maps **Parent Folder ID** to the folder from the previous step.
  </Step>

  <Step title="Share it">
    A **Google Drive File Share** action maps **File ID** to the uploaded file, sets **Email Address** to the recipient, and sets **Role** to `reader`.
  </Step>
</Steps>

## Troubleshooting

<AccordionGroup>
  <Accordion title="File or folder not found" icon="circle-question">
    The **File ID** or **Parent Folder ID** does not exist or the connected account cannot see it. Confirm the item is owned by or shared with the authenticated user.
  </Accordion>

  <Accordion title="Invalid base64 content" icon="triangle-exclamation">
    **File Content Base64** must be a valid base64 encoded string. Encode the file content before mapping it into the action.
  </Accordion>

  <Accordion title="Sharing failed" icon="user-slash">
    The **Permission Type** and **Email Address** combination is not valid. A `user` or `group` permission needs an email address, while `anyone` creates a public link with no email address.
  </Accordion>

  <Accordion title="Authentication failed" icon="lock">
    The Google OAuth credential expired or was revoked. Reconnect the credential and confirm the OAuth client grants Drive access.
  </Accordion>
</AccordionGroup>

For issues common to every vendor, see the [Actions overview](/building-and-deploying-agents/agent-basics/actions/overview#troubleshooting).
