Google Drive organizes resources primarily around files and shared drives. Files are the central entity: most actions (metadata read/write, content download/upload, comments, permissions, revisions) require a fileId. Shared drives (current API surface under drives.*) are identified by driveId (older teamDriveId parameters are present but deprecated). Permissions, comments, replies and revisions are always scoped to a particular fileId and then by permissionId, commentId, replyId, or revisionId as appropriate.
Key entities and relationships
-
Files: the primary resource. Use
fileIdto read metadata (files.get), download content (files.getwithalt=mediaorfiles.download/files.export), create (files.create), copy (files.copy), update (files.update), and manipulate parents (addParents/removeParents). Folder objects are files withmimeType = application/vnd.google-apps.folder. -
Permissions: attached to files or shared drives. Typical flow is
permissions.list→ inspect →permissions.create/permissions.update/permissions.deleteto change sharing. -
Comments and replies: always under a
fileId. Usecomments.*andreplies.*endpoints to create, list, update, and delete discussion threads on a file. -
Revisions: per-file version history. Use
revisions.list/get/update/delete. ThekeepForever(pinned) limit is product-level (see gotchas). -
Shared drives: managed with
drives.*. Usedrives.listto discoverdriveIds; many file operations accept adriveIdor requiresupportsAllDriveswhen operating across My Drive and shared drives. -
Changes and Operations: change-tracking uses
changes.getStartPageToken→changes.list(supply the returnedpageToken). Watch endpoints produce push notifications (channels) and some content/downloads can surface as long-runningOperationresources that you can poll viaoperations.get.
First calls (entry points)
-
Discover what belongs to the user or a shared drive:
drive.files.listwith aqfilter ordriveIdto find files and obtainfileIds.drive.drives.listto find shared drives (driveId).
-
For change tracking: call
drive.changes.getStartPageTokento obtain apageTokento start listing changes. -
To prepare IDs before creation (shortcuts or pre-declared files):
drive.files.generateIdsreturns ready-to-use IDs. -
Get account-level info (user, storage limits):
drive.about.get.
Start with files.list or drives.list when users ask for file discovery, and with about.get for account context.
Common user tasks and the minimal sequences to achieve them
Each sequence lists the operations you will call and the key parameters to provide (do not repeat obvious type details shown in operation signatures).
- Find a file or folder by name or other metadata
- Call
drive.files.listwith aqquery (e.g.name = 'Report.docx' and trashed = false) and optionaldriveId/corpora/spacesdepending on scope. UsepageTokenwhen results paginate.
- Read file metadata and content
- Get metadata:
drive.files.getwithfileId. - If the file is a Google Workspace doc (Docs/Sheets/Slides), export its content in a chosen format with
drive.files.exportand themimeTypeto receive the converted content. - For binary/non-native files or to download a specific revision, use
files.get/files.downloadwithalt=mediaor arevisionId. Note: some download flows return anOperationresource; check the response and, if you receive anOperation, polloperations.getusing the returned operation name.
- Upload a new file or create a folder
- Create folder:
drive.files.createwith body containingnameandmimeType: application/vnd.google-apps.folderand optionalparentsto place it. - Upload file content:
drive.files.createwith file metadata in the body. Provideparentsto put the file into a folder. To place files in shared drives, includesupportsAllDrives=trueand/ordriveIdas needed.
- Copy a file (create a new file from an existing one)
drive.files.copywith the sourcefileIdand optional body to set a newnameorparents.- Note: copying files into multiple parents is deprecated—use shortcuts if you need a file to appear in multiple places.
- Share a file or change access
- Inspect current access:
drive.permissions.listwithfileId. - Grant access:
drive.permissions.createwithfileIdand a permission body (type:user/group/domain/anyone, role:reader/writer/owner, andemailAddresswhen appropriate). To transfer ownership, settransferOwnership=trueand confirm withrole: 'owner'. - Adjust notification:
sendNotificationEmaildefaults to true for user/group shares; ownership transfers require notifications and cannot disable them.
- Work with comments and replies
- Create a comment:
drive.comments.createwithfileIdand comment body. - List comments:
drive.comments.list(filter withstartModifiedTimeif needed). - Create a reply:
drive.replies.createwithfileIdandcommentId. - Deleted comments/replies are returned only when
includeDeleted=true.
- Manage revisions
- List revisions:
drive.revisions.listwithfileId. - Pin a revision (
keepForever):drive.revisions.updateand setkeepForever=true. There is a platform limit on the number of revisions that can be pinned (200); if the limit is reached, older pins must be removed before pinning new revisions.
- Track changes and receive notifications
- Start:
drive.changes.getStartPageTokento obtain the token to feed intodrive.changes.list. - Poll or page through
drive.changes.listusing the token; includeincludeItemsFromAllDrives,driveId, andrestrictToMyDriveaccording to scope. - For push notifications, call
drive.changes.watch(supply a channel body). To stop a channel, calldrive.channels.stop.
- Handle shared drive lifecycle
- Create a shared drive:
drive.drives.createwith a client-suppliedrequestIdto make creation idempotent (a repeated request with the samerequestIdwill not create duplicates; if the drive already exists, expect a 409). - Delete a shared drive:
drive.drives.delete—if you need to delete items inside the drive,useDomainAdminAccess=trueandallowItemDeletion=trueare required (domain admin scenarios).
Long-running / asynchronous results
Some endpoints return or surface long-running Operation resources (for example certain downloads or other background tasks). When an operation resource appears in a response, use the operation's name with drive.operations.get to observe completion and retrieve results. The presence of an Operation in a response indicates the task is asynchronous—check done and the operation payload.
Frequent parameters and their effects (patterns rather than full lists)
fileId: required for almost all file-scoped actions; obtain it fromfiles.listor search results.driveIdvsteamDriveId: usedriveIdfor shared drives;teamDriveIdis deprecated in favor ofdriveId.supportsAllDrives: set to true when working across My Drive and shared drives (list/get/copy/update operations often need this when files may live in shared drives).useDomainAdminAccess: required for domain-administrator privileged operations on shared drives and permissions; this can grant access for administrative tasks.pageToken/pageSize: present on list endpoints—usepageTokenfrom prior responses to continue listing.includePermissionsForView: onlypublishedis supported; include only when you specifically need that view.
Non-obvious gotchas and practical tips
-
Google Workspace native files (Docs/Sheets/Slides) must be exported via
drive.files.exportto get payloads in common formats (PDF, DOCX, XLSX, etc.). Usingfiles.get/alt=mediawill not convert native docs—useexportfor conversions. -
files.downloadin this surface can return anOperation(async). If the response is anOperation, polldrive.operations.getwith the returned operation name. Always inspect the response body type to determine whether content is returned directly or via an operation. -
Copying into multiple parents is deprecated. If users want a file to appear in multiple folders, create a shortcut instead.
-
When transferring file ownership: set
transferOwnership=trueon thepermissions.createorpermissions.updatecall. Ownership transfers may move the item to the new owner’s root whenmoveToNewOwnersRoot=trueis set (only applies outside shared drives). Notifications for ownership transfers cannot be suppressed. -
Shared drive creation is idempotent when you provide a
requestId. Repeating the samerequestIdwill not create duplicates; if a drive with the same identity exists, expect a 409 conflict. -
Deleting a shared drive’s contents requires admin privileges:
useDomainAdminAccess=trueplusallowItemDeletion=trueondrives.deleteto remove items inside in domain-admin scenarios. -
supportsTeamDrivesandteamDriveIdparameters are deprecated—prefersupportsAllDrivesanddriveId. -
Revisions pinned with
keepForever=trueare limited (200 pinned revisions per file). If a pin fails due to quota, unpin older revisions first viarevisions.update. -
Label-related operations (
files.listLabels,files.modifyLabels) return and acceptlabeldata separate from file metadata. IncludeincludeLabelsin calls that can return labelInfo when you expect label details. -
Permissions API behavior varies by scope:
useDomainAdminAccesscan grant domain-level privileges for admin flows, andenforceExpansiveAccessexists to control enforcement semantics. When in doubt, list permissions first (permissions.list) to see current state before applying changes.
When a user asks something typical, what to call first
- “Show me my recent files”: call
drive.files.listordered bymodifiedTimeorrecencywith the appropriateqfilter. - “Download X document as PDF”: find
fileIdviafiles.list, then calldrive.files.exportwithmimeType=application/pdf. - “Share this file with alice@example.com as editor”:
drive.permissions.createwithfileIdand permission body (type: 'user', emailAddress: 'alice@example.com', role: 'writer'), setsendNotificationEmailas desired; includetransferOwnership=trueonly if making owner. - “Watch for changes in my Drive”: call
drive.changes.getStartPageTokenthendrive.changes.listwith the returned token; usedrive.changes.watchif push notifications are preferred.
Focus on obtaining fileId and driveId early—most errors come from operating on the wrong scope (My Drive vs shared drive) or failing to set supportsAllDrives / useDomainAdminAccess when needed. Use files.list and drives.list to discover IDs and then follow the small, task-specific sequences above to complete user requests.