Google Drive keeps track of all changes made to a file by automatically maintaining version history. This allows users to see who made edits and to revert to earlier versions of the same file. The Drive API refers to each change as a "Revision" and provides access to revisions through the Revisions resource.
The Drive API allow you to programmatically save new revisions of a file or query the version history as detailed in the Revisions.
Google Drive automatically purges (or "prunes") older revisions in order to optimize disk usage. To prevent this from happening, you can set the boolean flag
true to mark revisions that you don't want Drive to purge.
List and download individual revisionsOnce 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
downloadUrlproperty. 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.
Publish a revision
For Google Docs, Sheets, and Slides you can publish any revision to the web by setting the
published property. If the file is created in a G Suite 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.