export_revision
Export a historical revision of a Google Sheet or Doc to recover cell data or Markdown; find the revision ID with list_revisions first.
Instructions
Export a historical revision of a Google Sheets file (cell data) or a Google Doc (Markdown). Use list_revisions to find the revision_id.
Google Sheets: downloads the revision as XLSX and returns the values for the requested sheet and range. Typical recovery workflow:
list_revisions → find the revision ID from the timestamp before data was lost
export_revision → read the affected range from that revision
batch_update_cells → write the recovered values back to the current sheet Each call downloads the full file, so a large spreadsheet may be slow.
Google Docs: returns the revision as Markdown, converted the same way as get_doc_as_markdown. The Docs API can only read a document's current state, so the revision is exported as DOCX, imported into a temporary Google Doc, converted, and the temporary Doc is deleted (trashed if this identity can't delete it), so this call writes to Drive even though it changes nothing of yours. Expect several seconds per call. Two revisions' exports diff cleanly, with these differences from get_doc_as_markdown's output:
A link to a heading in the document renders as "#slug" (GitHub style), not a docs.google.com URL. A link to a bookmark, or to a heading that doesn't render as one (e.g. a heading in a table cell), is dropped, leaving its text.
An image renders as "image:sha256-", so an unchanged image doesn't show up in a diff. No viewable URL is returned: the temporary Doc's image URLs stop working once it's deleted.
Comments aren't included: they aren't part of a revision.
Args: file_id: The Google Drive file ID of the spreadsheet or document. revision_id: The revision ID from list_revisions. range: Sheets only. A1 notation range to return, e.g. "A1:D20". Omit for all data. sheet: Sheets only. Sheet (tab) name. Defaults to the first sheet. local_path: Docs only. Local path to write the Markdown to instead of returning it inline (the raw Markdown text, UTF-8). A directory path writes <file_id>-r<revision_id>.md inside it; a path ending in '/' is a directory, created if missing. A file in place of a parent directory, or at a path ending in '/', raises ValueError before the export; an existing file at a plain file path is replaced. Bypasses the response-size cap.
Returns: Sheets: revisionId, modifiedTime, sheet name, range, and values as a list of rows. Docs: revisionId, modifiedTime, and markdown, plus warning if the temporary Doc couldn't be removed (it names the Doc's ID). With local_path, local_path and bytes_written replace markdown. Raises ValueError for a file that is neither a Sheet nor a Doc, for an argument that doesn't apply to the file's type, for a revision ID that no longer exists, for a local_path with a non-directory component (checked before the export), or if a Docs response exceeds the size cap without local_path.
Note: For a Doc, a user identity (OAuth, or ADC with user credentials) creates the temporary Doc in My Drive root, not shared with anyone. That needs room in My Drive and permission to create files there, even when the default folder is a Shared Drive. A service account has no My Drive storage, so it uses the default folder, which must be a Shared Drive: that drive's members can open the copy while the export runs.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"file_id": "<file_id>",
"revision_id": "<revision_id>"
},
"name": "export_revision"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| range | No | ||
| sheet | No | ||
| file_id | Yes | ||
| local_path | No | ||
| revision_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||