> ## 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.

# Branches, Snapshots, Versions & Primitives

> Test AI edits on draft branches, save zero-quota restore points, check 30 or 90 day File Version History, and edit structured data safely.

Let agents make big edits safely without overwriting your live files.

## Draft branches

Put risky edits onto a separate branch, check diffs, and merge when ready.

**1. Work on a branch**

```bash theme={null}
zd branch create feat/q4-docs --drive primary
```

`branch_read_file` falls back to `main` for untouched files, while `branch_write_file` and `branch_delete_file` stay inside your branch.

**2. Inspect and merge**

```bash theme={null}
zd branch diff feat/q4-docs
zd branch merge feat/q4-docs --strategy fail
```

Merging saves previous files into **File Version History** first and supports `--dry-run`, `fail`, `ours`, or `theirs`.

## Locked restore points (Snapshots)

Save a point-in-time snapshot before major cleanups (`zd snapshot create --label "before-cleanup"`, `zd snapshot list`, `zd snapshot restore <id>`). Snapshots use **zero quota**, and restoring saves a safety backup first by default.

## File Version History

Every overwrite keeps prior versions (`ver_...`) for **30 days on Pro** or **90 days on Pro Max and Agency**. Inspect, diff, and restore anytime (`list_file_versions`, `diff_file_versions`, `restore_file_version`, or `zd versions`).

## Targeted structured file edits

Edit JSON, JSONL, CSV, Markdown, or YAML files directly without downloading and re-uploading whole files.

| Action | Tool or endpoint | What it does |
| :- | :- | :- |
| **Patch** | `patch_structured_file` (`POST /v1/primitives/patch`) | Updates chosen fields or sections safely. |
| **Append JSONL** | `append_jsonl` (`POST /v1/primitives/append-jsonl`) | Appends valid JSON lines with optional dedupe. |
| **Query** | `query_structured_file` (`POST /v1/primitives/query`) | Queries CSV rows, JSON paths, Markdown sections, or YAML keys. |
| **Merge** | `merge_file` (`POST /v1/primitives/merge`) | Merges parallel edits across structured files cleanly. |


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