> For the complete documentation index, see [llms.txt](https://learn.mechanic.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.mechanic.dev/platform/integrations/google-drive-and-google-sheets.md).

# Google Drive and Google Sheets

Mechanic provides a streamlined integration with Google Drive and Google Sheets, allowing you to automate common file management and spreadsheet operations without having to directly interface with the Google Drive API.

### Authentication

{% hint style="info" %}
You can connect more than one Google account choosing which account to use when writing your task code.
{% endhint %}

Before using Google integrations connect your Google accounts:

1. Go to **Settings → Authentication** in Mechanic
2. Select **Google** in the provider list
3. Connect your Google account
4. Grant the necessary permissions when prompted

### Google Drive Integration

The Google Drive action allows you to upload and manage files in Google Drive.\
\
See in-depth documentation of the Google Drive action [here](/core/actions/integrations/google-drive.md).

#### Basic Usage

```liquid
{% action "google_drive" %}
  {
    "account": "your.email@example.com",
    "uploads": {
      "overwrite": true,
      "simple.txt": "Hello, world!",
      "report.pdf": {
        "pdf": {
          "html": "<h1>Report</h1><p>Content here</p>"
        }
      }
    }
  }
{% endaction %}
```

#### Supported Features

* Upload multiple files in a single action
* Paths can include folders (e.g., 'reports/monthly/file.txt')
* Overwrite existing files (optional)
* Generate various file types (TXT, PDF, CSV, HTML, etc.) using Mechanic [File generators](/core/actions/file-generators.md) or linking from external URLs (e.g. Shopify Files - CDN)

### Google Sheets Integration

The Google Sheets action enables focused interaction with spreadsheets, including creating spreadsheets with one or many sheets, reading and writing data, deleting rows, managing sheets (tabs), and exporting. \\

See in-depth documentation of the Google Sheets action [here](/core/actions/integrations/google-sheets.md).

#### Basic Usage

```liquid
{% action "google_sheets" %}
  {
    "account": "your.email@example.com",
    "operation": "append_rows",
    "spreadsheet_id": "your-spreadsheet-id",
    "sheet_name": "Sheet1",
    "rows": [
      ["Column1", "Column2", "Column3"],
      ["Value1", "Value2", "Value3"]
    ]
  }
{% endaction %}
```

#### Supported Operations

* `create_spreadsheet`: Create new spreadsheets, with one or many named sheets
* `append_rows`: Add data to existing spreadsheets
* `update_rows`: Overwrite data at a specific range
* `clear_values`: Clear values from a range or a whole sheet
* `get_values`: Read values from a spreadsheet into the action result
* `delete_rows`: Delete a span of rows from a sheet
* `add_sheet`: Add a sheet (tab) to an existing spreadsheet
* `rename_sheet`: Rename a sheet (tab)
* `delete_sheet`: Delete a sheet (tab)
* `export_spreadsheet`: Export spreadsheets in various formats

### File Type Support

#### Drive Upload Formats

* Text files
* PDFs (generated from HTML)
* CSV files
* HTML files
* Any binary file format (e.g. ZIP)

#### Sheets Export Formats

* XLSX (Excel)
* CSV
* PDF
* HTML
* ODS
* TSV

### Permissions

The integration requires the `https://www.googleapis.com/auth/drive.file` scope, which allows:

* Access to files created by the app
* Access to files explicitly shared with the app
* No access to other files in your Google Drive


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://learn.mechanic.dev/platform/integrations/google-drive-and-google-sheets.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
