How to change the name of a Google Docs revision using code

I’m working with a Google Docs file and need to programmatically update the name of a specific revision. I want to give it a custom label like “Release v2.0 - 20241215” or something similar.

I’m open to using any programming language (Python, JavaScript, etc.) or direct REST API calls. Even if I can only rename the most recent revision, that would work for my needs.

I already have code that retrieves all document revisions, but I’m stuck on the actual renaming part. Here’s what I’m using to fetch the revision list:

import os
from google.oauth2 import service_account
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError

def fetch_document_revisions(document_id):
    CREDENTIALS_FILE = 'credentials.json'
    STORAGE_PATH = 'files'
    target_folder = os.path.join(STORAGE_PATH, document_id)
    
    if not os.path.exists(target_folder):
        os.makedirs(target_folder)
    
    # setup authentication using service account
    creds = service_account.Credentials.from_service_account_file(
        CREDENTIALS_FILE,
        scopes=['https://www.googleapis.com/auth/documents',
                'https://www.googleapis.com/auth/drive']
    )
    
    # create Drive API client (v2 required)
    api_client = build('drive', 'v2', credentials=creds)
    
    try:
        # retrieve all revisions for the document
        revision_list = api_client.revisions().list(fileId=document_id).execute()
        print(f"Found {len(revision_list['items'])} revisions for document {document_id}")
        
    except HttpError as err:
        print(f"Error occurred: {err}")
        raise err

if __name__ == '__main__':
    doc_id = "1U_Be02ViQp0UKPYNQo184ks4Vv-ey8mNoawJtTyC1R8"
    fetch_document_revisions(doc_id)

I’ve searched through the API documentation but haven’t found a method to actually modify revision names. Has anyone successfully done this before?

Yeah, Luna23’s right about this limitation. Hit the same wall last year building an automated docs system. Both Google Drive API v2 and v3 make revision names read-only - they’re auto-generated from timestamps and modification patterns. My workaround was keeping a separate metadata file that maps revision IDs to custom labels. Since your code already pulls the revision list with IDs, just store those IDs with your custom names like “Release v2.0 - 20241215”. It’s ugly but works for tracking. You could also use Google Drive’s file description field or custom properties to store version info at the document level instead of revision level. Won’t give you per-revision labeling but might work for release tracking.

nope, u cant rename revisions with the google drive api - they get auto generated and cant be changed. ive hit that wall too. maybe consider using version history to keep tracking ur releases instead of messing with revision names.

Unfortunately, this is a dead end with the current API design. Google treats revision names as system-generated metadata that can’t be modified through any official endpoint. I spent a lot of time exploring this same issue for a document management system and confirmed that both Drive API versions completely lock down revision naming. The closest workaround I found was using Google Apps Script to create custom properties on the document itself. You can store revision-to-label mappings in the document’s custom properties using PropertiesService. This gives you programmatic access to your version labels without maintaining external files. The approach keeps metadata attached to the document and accessible through the same authentication flow you’re already using. Not perfect since it doesn’t change the actual revision names, but it’s a clean way to associate custom labels with specific revision IDs.