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

# Google Drive

> Sync files from a Google Drive folder or shared drive into Mixpeek

Mixpeek reads files directly from Google Drive — personal folders, shared drives, and team collaboration folders. You create a storage **connection** (how to authenticate), then a bucket **sync** that points at a folder. New and changed files are picked up automatically.

> [!NOTE]
>
> Mixpeek only **reads** from your Drive. It never writes or deletes files in your Drive.

## 1. Authenticate

Two auth methods are supported. **Service account** is recommended for unattended, server-to-server sync.

> [tab] Service account (recommended)
>
> 1. In Google Cloud Console, create a **service account** and download its JSON key.
> 2. **Share the target Drive folder (or shared drive) with the service account's `client_email`** — this is what grants Mixpeek access. Viewer permission is enough.
> 3. Create the connection with the fields from the JSON key file:
>
> ```bash theme={null}
> curl -sS -X POST "$MP_API_URL/v1/organizations/connections" \
>   -H "Authorization: Bearer $MP_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "name": "Marketing Google Drive",
>     "provider_type": "google_drive",
>     "provider_config": {
>       "provider_type": "google_drive",
>       "credentials": {
>         "type": "service_account",
>         "project_id": "my-project",
>         "private_key_id": "<from JSON key file>",
>         "private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
>         "client_email": "sync@my-project.iam.gserviceaccount.com",
>         "client_id": "<from JSON key file>"
>       },
>       "shared_drive_id": "0AH-Xabc123"
>     }
>   }'
> ```
>
> `shared_drive_id` is optional — include it only when syncing a **shared drive** (find it in the drive's URL). For a folder in a regular My Drive, omit it and point the sync at the folder ID instead (step 2). `private_key` and the other secrets are encrypted at rest.

> [tab] OAuth
>
> Use OAuth when syncing a specific user's Drive. Supply a client ID/secret and a long-lived refresh token:
>
> ```bash theme={null}
> curl -sS -X POST "$MP_API_URL/v1/organizations/connections" \
>   -H "Authorization: Bearer $MP_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "name": "My Drive",
>     "provider_type": "google_drive",
>     "provider_config": {
>       "provider_type": "google_drive",
>       "credentials": {
>         "type": "oauth",
>         "client_id": "<oauth client id>",
>         "client_secret": "<oauth client secret>",
>         "refresh_token": "<long-lived refresh token>"
>       }
>     }
>   }'
> ```

The response includes a `connection_id` (`conn_...`).

> [!TIP]
>
> List folders and files the connection can see with `GET /v1/organizations/connections/{connection_id}/folders` and `…/files` — handy for finding the folder ID to sync.

## 2. Sync a folder into a bucket

Create a [bucket](https://docs.mixpeek.com/docs/platform/data-model.md) first, then attach a sync. `source_path` is the **Drive folder ID** (the trailing segment of the folder's URL, e.g. `1A2b3C...`):

```bash theme={null}
curl -sS -X POST "$MP_API_URL/v1/buckets/$BUCKET_ID/syncs" \
  -H "Authorization: Bearer $MP_API_KEY" \
  -H "X-Namespace: $MP_NAMESPACE" \
  -H "Content-Type: application/json" \
  -d '{
    "connection_id": "conn_abc123",
    "source_path": "1A2b3C4d5E6f7G8h9I",
    "sync_mode": "continuous",
    "polling_interval_seconds": 3600
  }'
```

Then trigger the first sync:

```bash theme={null}
curl -sS -X POST "$MP_API_URL/v1/buckets/$BUCKET_ID/syncs/$SYNC_ID/trigger" \
  -H "Authorization: Bearer $MP_API_KEY" -H "X-Namespace: $MP_NAMESPACE"
```

After the initial sync, new and changed files in the folder are picked up automatically at the polling interval. See [Syncs](https://docs.mixpeek.com/docs/platform/syncs.md) for file/metadata filters, `on_delete` cascade behavior, and monitoring.

## Next steps

* [Syncs reference](https://docs.mixpeek.com/docs/platform/syncs.md) — filters, reconciliation, lifecycle, and robustness
* [Object Storage overview](https://docs.mixpeek.com/docs/integrations/object-storage/overview.md) — all supported providers
* [Ingest Data](https://docs.mixpeek.com/docs/platform/data-model.md) — buckets, objects, and batches


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