Skip to content

Drive Access API

Read, search, upload, and manage Google Drive files — including Google Docs and Sheets content — through PortEden Access Tokens. All endpoints use Bearer token authentication and a three-layer security model.

Base URL

https://cliv1b.porteden.com/api/access/drive

Rate Limits

60 req/min · 300 req/hr per IP

Quick Reference

EndpointMethodOperationDescription
/filesGETlist_files / search_filesSearch and list files
/files/{fileId}GETget_file_metadataGet file metadata
/files/{fileId}/downloadGETdownload_fileGet file links (view, download, export)
/files/{fileId}/permissionsGETget_file_metadataGet sharing permissions
/files/uploadPOSTupload_fileUpload a new file
/foldersPOSTcreate_folderCreate a new folder
/files/{fileId}/renamePATCHrename_fileRename a file/folder
/files/{fileId}/movePATCHmove_fileMove to another folder
/files/{fileId}DELETEdelete_fileMove file to trash
/files/{fileId}/sharePOSTshare_fileShare with user/group/domain
/docs/{fileId}/contentGETread_doc_contentRead Google Doc content
/docs/{fileId}/editPOSTedit_doc_contentEdit Google Doc text
/sheets/{fileId}GETread_sheet_dataGet spreadsheet metadata
/sheets/{fileId}/valuesGETread_sheet_dataRead cell values from a range
/sheets/{fileId}/valuesPUTwrite_sheet_dataWrite cell values to a range
/sheets/{fileId}/values:appendPOSTwrite_sheet_dataAppend rows after last data

Authentication

All endpoints require a PortEden Access Token via Bearer authentication:

Authorization: Bearer pe_k1_abc123def456...

The token must have:

  • driveAccessEnabled: true
  • At least one connected Google Drive provider with drive scopes
  • The relevant operation flag enabled in allowedDriveOperations

Provider Requirement

The platform-managed Google client does not request drive permissions. Users must configure a Custom OAuth app and re-authenticate to grant drive access. See Google OAuth Setup.

Access Control Model

Drive access uses a three-layer security model. The token must pass all layers for each request.

Layer 1: Operation Permissions

Each token has an allowedDriveOperations bitflag that controls which API operations it can perform.

Individual Operations

OperationDescription
list_filesList files in a folder
search_filesFree-text search across files
get_file_metadataGet a single file's metadata
download_fileGet file links (view, download, export URLs — no binary streaming)
upload_fileUpload a new file
create_folderCreate a new folder
rename_fileRename a file or folder
move_fileMove a file to a different folder
delete_fileMove a file to trash
share_fileShare a file with users/groups
update_permissionsUpdate sharing permissions
read_doc_contentRead text/structured content of Google Docs
edit_doc_contentInsert, replace, or append text in Google Docs
read_sheet_dataRead cell values and metadata from Google Sheets
write_sheet_dataWrite/update/append cell values in Google Sheets
edit_sheet_structureAdd/remove sheet tabs, formatting, merge cells

Shorthand Flags

ShorthandIncludes
read_onlylist_files + search_files + get_file_metadata + download_file
docs_read_onlyread_doc_content
docs_allread_doc_content + edit_doc_content
sheets_read_onlyread_sheet_data
sheets_allread_sheet_data + write_sheet_data + edit_sheet_structure
workspace_alldocs_all + sheets_all
allAll operations

Note

Default permission is read_only. Update permissions at Token Permissions.

Layer 2: Drive Rules (File-Level Firewall)

Drive rules determine which specific files the token can access. Rules are evaluated per-file against the file's properties.

Default Policy (driveAllowAll)

driveAllowAllWhen No Rules ExistWhen Rules Exist
false (default)All files blockedOnly files matching allow rules are accessible
trueAll files accessibleFiles matching block rules are hidden/denied

Rule Types

Rule TypeDescriptionPattern Example
file_idMatch a specific file by provider-prefixed IDgoogle:1BxiMVs0XRA5nkz...
mime_typeMatch files by MIME type (supports /* wildcards)application/pdf or image/*
folderMatch all files inside a specific foldergoogle:0B7_abc123...

Rule Actions

ActionDescription
allowPermit access to matching files
blockDeny access to matching files (always overrides allow rules)

Evaluation Order

  1. If no rules exist at all, the driveAllowAll default applies
  2. Each rule is checked against the file (case-insensitive exact match or wildcard for mime_type)
  3. If any block rule matches → file is blocked (block always wins)
  4. If any allow rule matches → file is allowed
  5. If no rule matches → falls back to driveAllowAll default

Example: Allow Everything Except Sensitive Content

{
"driveAllowAll": true,
"rules": [
{ "ruleType": "folder", "pattern": "google:0B7_HR_CONFIDENTIAL", "action": "block" },
{ "ruleType": "mime_type", "pattern": "application/vnd.google-apps.spreadsheet", "action": "block" }
]
}

Result: All files accessible except those in the HR folder and all spreadsheets.

HTTP Status Codes

StatusMeaning
200Success
204Success (no content — used by DELETE)
400Invalid request (missing fields, bad range format)
401Invalid or missing access token
403Operation not allowed or file access restricted
404File not found, no matching provider, or access restricted
422Drive not enabled on token, or no drive provider connected
429Rate limit exceeded
500Provider error communicating with Google Drive

Drive Error Codes

Error CodeHTTPDescription
DRIVE_NOT_ENABLED422Token doesn't have driveAccessEnabled: true
NO_DRIVE_PROVIDER422No Google account connected with drive scopes
OPERATION_NOT_ALLOWED403Token's allowedDriveOperations doesn't include this operation
ACCESS_RESTRICTED403/404File access restricted by drive rules or owner filtering
NO_CONNECTION403No drive-capable connection found for this operation
NO_ADAPTER403No adapter found for the connection type — contact support
NOT_FOUND404File not found or no matching provider connection
PERMISSION_DENIED403/404Connected Google account lacks access to this file
READONLY_SCOPE403Connected Google account has read-only Drive scope and cannot write
INVALID_REQUEST400Missing required fields, invalid operation type, or exceeds limits
INVALID_RANGE400Malformed Sheets range parameter
PROVIDER_ERROR500Unexpected error communicating with Google Drive

Supported Providers

ProviderFile ID PrefixRequirements
Google Drivegoogle:Custom OAuth app with drive scope

Scope Requirements for Docs & Sheets

Read operations (doc content, sheet values, metadata) work with drive.readonly, drive, or drive.file scopes.
Write operations (edit doc, write/append sheet values) require drive or drive.file scope — drive.readonly connections return a READONLY_SCOPE error.
No additional Docs-specific or Sheets-specific OAuth scopes are needed.