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

> ## Agent Instructions
> These docs describe the Ancha CLI, npm package @ancha-labs/cli version 0.1.4, and the hosted workspace at app.ancha.io. Coding agents should start at https://docs.ancha.io/coding-agents. Run the CLI as `ancha` after `npm install -g @ancha-labs/cli`, or as `npx -y @ancha-labs/cli@0.1.4` without installing. Pass --json for machine-readable output, or set ANCHA_JSON=1. Every command ends with a `next:` line naming the next command. Exit codes: 0 pass, 1 a check failed or a comparison regressed, 2 usage, config or authentication error, 3 infrastructure error, 4 unimplemented endpoint with --strict.

# Google Drive

> A stateful replica of the Google Drive API v3: files and folders in one My Drive, uploads and exports, permissions, comments, revisions and changes.

The Google Drive replica implements 26 endpoints of the Drive API v3 for one signed-in account's My Drive, with Docs, Sheets and Slides stored as text. Its key is `google-drive`. It was tested with `@googleapis/drive`.

## Connect

| Variable | Value |
| - | - |
| `GOOGLE_DRIVE_API_URL` | Base URL. Paths start with `/drive/v3/` and `/upload/drive/v3/`. |
| `GOOGLE_DRIVE_ACCESS_TOKEN` | Fake OAuth access token for the agent's account. Send `Authorization: Bearer <token>`. |

```js Node theme={null}
import { auth, drive } from '@googleapis/drive';
const oauth = new auth.OAuth2();
oauth.setCredentials({ access_token: process.env.GOOGLE_DRIVE_ACCESS_TOKEN });
const files = drive({ version: 'v3', auth: oauth });
const options = { rootUrl: process.env.GOOGLE_DRIVE_API_URL + '/', retry: false };
const { data } = await files.files.list({ q: "trashed = false", fields: 'files(id, name, mimeType)' }, options);
```

This is what `ancha connect google-drive --lang ts` prints. Google's client takes the replica as a per-request `rootUrl` ending in `/`; a global `rootUrl` keeps only the origin and drops the path.

## Endpoints

| Method | Path | Notes |
| - | - | - |
| `GET` | `/drive/v3/about` | `fields` is required, as in Drive. |
| `GET` | `/drive/v3/files` | `q` supports `name`, `fullText`, `mimeType`, `parents`, `owners`, `writers`, `readers`, times, `trashed`, `starred`, `sharedWithMe` and `visibility`. `properties has` is a gap. |
| `POST` | `/drive/v3/files` | Metadata only: folders and empty files. |
| `POST` | `/upload/drive/v3/files` | `uploadType=multipart` or `media`. Text converts to Docs, Sheets and Slides. Resumable uploads are a gap. |
| `DELETE` | `/drive/v3/files/trash` | Empties the trash. |
| `GET` | `/drive/v3/files/{fileId}` | `alt=media` downloads binary content. `root` is the account's My Drive. |
| `PATCH` | `/drive/v3/files/{fileId}` | Rename, describe, star, trash (owner only), properties, and moves with one `addParents` and `removeParents`. |
| `PATCH` | `/upload/drive/v3/files/{fileId}` | Replaces content and keeps a revision. |
| `DELETE` | `/drive/v3/files/{fileId}` | Owner only; skips the trash. |
| `POST` | `/drive/v3/files/{fileId}/copy` | |
| `GET` | `/drive/v3/files/{fileId}/export` | Docs to text, Markdown or HTML; Sheets to CSV or TSV; Slides to text. PDF and Office formats are gaps. |
| `GET`, `POST` | `/drive/v3/files/{fileId}/permissions` | Lists include the owner and inherited grants. Grants to users, groups, a domain and anyone. Notification emails are recorded, not sent; ownership transfer and expirations are gaps. |
| `GET`, `PATCH`, `DELETE` | `/drive/v3/files/{fileId}/permissions/{permissionId}` | Role changes on the file's own grants. |
| `GET`, `POST` | `/drive/v3/files/{fileId}/comments` | `fields` is required. Comments are unanchored, optionally quoting text. |
| `GET`, `PATCH`, `DELETE` | `/drive/v3/files/{fileId}/comments/{commentId}` | |
| `GET`, `POST` | `/drive/v3/files/{fileId}/comments/{commentId}/replies` | A reply with `action` `resolve` or `reopen` changes the comment's state. |
| `GET` | `/drive/v3/files/{fileId}/revisions` | Writers and owners only. |
| `GET` | `/drive/v3/changes/startPageToken` | |
| `GET` | `/drive/v3/changes` | Changes the account can see, one entry per file per page. Push notifications are a gap. |

All 26 endpoints are partial. Anything else returns HTTP 501 with Google's error shape and `x-ancha-gap: 1`.

## Starter data

The `google-drive-starter` dataset is the My Drive of `ancha@acme.example` in the domain `acme.example`, with eleven users and thirty files. The agent sees what is shared with it: the company folder **Acme**, which everyone in the domain can edit, and a few files shared directly.

| Folder | Contents |
| - | - |
| `Acme/Product` (Ellen Price) | "Scheduled reports spec", a Doc with three comments from Laura and Greg; "Roadmap review: Thursday topics"; the Sheet "Customer feedback: October". |
| `Acme/Marketing` (Tom Hughes) | "Ridgeway Robotics case study (draft)" with a resolved comment; "Acme product overview\.pdf", shared with anyone who has the link. |
| `Acme/Customers/Ridgeway Robotics` (Laura Kim) | "Ridgeway Robotics pilot plan" and `ridgeway-warehouse-tables.csv`. Erin Walsh at Ridgeway can comment on this folder. |
| `Acme/Customers/Pinecrest Health` | "Pinecrest Health order form: 20 additional seats" (a draft) and the Sheet "Pinecrest Health onboarding checklist". |
| `Acme/Customers/Bluefield Logistics` | "Bluefield Logistics security questionnaire" with a comment from Greg, and "Acme SOC 2 Type II report 2026.pdf", described as "Share only under NDA, as view-only". |
| `Acme/Engineering` (Ben Carter) | "Orders API runbook" and "Postmortem: Orders API latency after 4.12.1", a draft with a comment. |
| `Finance` (Anna Fischer) | The Sheets "Purchase orders 2026" and "October expense reports". Mike can edit; Ben and the agent can read. |
| `Leadership` (Mike Turner) | "Board deck draft: Q4", a presentation. Shared with Ben only; the agent cannot see it. |
| My Drive root | "Weekly support digest: Oct 24", owned by the agent and shared with the domain, plus a trashed copy. Ben's private "Ben notes" is not shared. |

`ancha sandbox configuration --tools google-drive --json` prints every file with its ID, owner, permissions and content.

## Checks

Google Drive has no state checks. Use trace checks, for example `{ called: "POST /drive/v3/files/*/permissions" }` or `{ not_called: "DELETE /drive/v3/files/*" }`.

## Limits

* My Drive for one signed-in account: no shared drives, push notifications or resumable uploads.
* Exports cover text, Markdown, HTML, CSV and TSV; PDF and Office exports are coverage gaps.
* Sharing notifications are recorded in state, never emailed.


## Related topics

- [Tools](https://docs.ancha.io/tools/overview.md)
- [Introduction](https://docs.ancha.io/index.md)
- [Test file (scene.yaml)](https://docs.ancha.io/reference/test-file.md)
- [ancha connect](https://docs.ancha.io/cli/connect.md)
- [Environment variables](https://docs.ancha.io/reference/environment-variables.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.