Hide
Drive REST API

Manage Revisions

Google Drive keeps track of all changes made to a file by automatically creating a "revision history." This allows users to see who made edits and to revert to earlier versions of the same file.

With the Drive API, you can programmatically save new revisions of a file or query the revision history as detailed in the Revision reference.

Google Drive automatically purges (or "prunes") revisions in order to optimize disk usage. To prevent this from happening, you can set the boolean flag pinned to true to "pin" revisions that you don't want Drive to purge.

Listing and downloading individual revisions

Once you get a list of a file's revisions, you can download the content of any revision by sending an authorized GET request to its downloadUrl property. Google Drive generates this short-lived URL when you request the revision — don't rely on it for later use.

You can also export the revision in one of the supported formats by checking the exportLinks property.

Publishing revisions

You can publish any revision to the web by setting the published property. Published revisions expose a property called publishedLink, which points to the published file on the web. If the file is created in a Google Apps domain, the publishedOutsideDomain property indicates whether the revision is accessible by anyone or if it is restricted to users of the domain.

Published revisions do not reflect changes made to a file unless the publishAuto property is set. If that property is set to true, newer revisions of a file will be automatically published, overwriting the previous ones. This behavior is also controlled by the "Automatically re-publish when changes are made" checkbox in the Drive UI.

Tips and tricks

To learn more about revisions, you can watch the following video of Google engineers discussing related tips and tricks.