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

> ## Agent Instructions
> Hosted remote MCP endpoint: https://api.zerodrive.dev/mcp (OAuth 2.0 PKCE or Bearer token).
> REST API base URL: https://api.zerodrive.dev with OpenAPI 3.1.0 specification at https://api.zerodrive.dev/openapi.json.
> S3-compatible gateway: https://api.zerodrive.dev/s3 (AWS Signature V4, region auto).
> Local command-line tool: zd (or zerodrive) and local stdio MCP server: zerodrive mcp.
> Token prefixes: zdk_ (Personal API Key), zdt_ (device session token), zda_ (OAuth access token), zdr_ (OAuth refresh token), zdx_ (temporary sandbox key). Never paste real keys into prompts or code.
> Be honest about platform boundaries: cloud files require internet access, files are encrypted at rest and in transit by Cloudflare rather than end-to-end encrypted, ZeroDrive is not a replacement for an independent backup, Windows 11 support is an unsigned x64 beta, and the 7-day Pro free trial requires a card and charges automatically when it ends.

# Authentication & Credentials

> Authenticate with Personal API Keys (zdk_), Device Tokens (zdt_), OAuth 2.0 (zda_/zdr_), Sandbox Keys (zdx_), or S3 keys.

Pass your bearer token in `Authorization`.

```bash theme={null}
curl -sS https://api.zerodrive.dev/v1/files \
  -H "Authorization: Bearer zdk_your_api_key"
```

## Five key types

| Key | Prefix | Source | Expiry | Limits |
| :- | :- | :- | :- | :- |
| **API Key** | `zdk_` | `#connect` (max 25 keys) | Never, 30d, 90d, 1yr (hashed) | Optional scope & `root_folder` lock. No credentials/admin routes. |
| **Device** | `zdt_` | Desktop app or `zd login` | Keychain / Credential Manager (hashed) | Unlocks `/v1/me/credentials`, `/v1/me/usage`, `/v1/duplicates/remove`. |
| **OAuth** | `zda_` / `zdr_` | `/oauth/authorize` or `/oauth/register` | Confidential `1h` + `90d` refresh. PKCE `1yr` | Limited by scopes, consent, and `root_folder`. No duplicate removal. |
| **Sandbox** | `zdx_` | `POST /v1/sandboxes` | Custom TTL (hashed) | Locked to 1 `drive_id`, optional `root_folder` and `branch`. |
| **S3 Keys** | `zdk_` | `#connect` or `/v1/me/credentials` | Active until rotated | Works only on `https://api.zerodrive.dev/s3` (SigV4). |

## PKCE browser login flow

Desktop apps and scripts obtain a `zdt_` token safely without bundling client secrets.

**1. Start handoff (POST /v1/auth/handoff/start)**

Generate a random `code_verifier` and its base64url SHA-256 `code_challenge`. Only `zerodrive://auth` and local `http://127.0.0.1:<1024-65535>/callback` redirects are accepted.

```json theme={null}
{
  "code_challenge": "<base64url_sha256_of_verifier>",
  "redirect_uri": "http://127.0.0.1:49200/callback"
}
```

**2. Exchange code (POST /v1/auth/handoff/exchange)**

```json theme={null}
{
  "handoff_id": "<handoff_id>",
  "code": "<one_time_code>",
  "code_verifier": "<original_verifier>"
}
```

Returns `device_token`, `account_id`, and `email` (invalid or reused codes return `400 invalid_grant`).

## OAuth scopes

`mcp`, `vault:read`, `vault:write`, `vault:delete`, `offline_access` (`90d` rotating `zdr_`), and `openid email profile` (`GET /userinfo`).


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