Google Docs
Read and edit the text content of Google Docs files. The connected Google account must have a writable Drive scope (drive or drive.file) for edit operations; drive.readonly connections can only read content.
Creating Google Docs
Use the Upload File endpoint with
mimeType=application/vnd.google-apps.document to create a new Google Doc, then edit its content using the endpoints below.GET
/api/access/drive/docs/{fileId}/contentBearer TokenRead Document Content
Returns the content of a Google Doc in plain text or structured JSON format.
Query Parameters
| Parameter | Default | Description |
|---|---|---|
| format | text | text — fast, uses Drive export. structured — full, uses Google Docs API with headings, lists, formatting. |
Required Operation
Requires
read_doc_content permission.Plain Text Response (default)
Response 200 OK
{ "plainText": "This is the document content.\n\nSecond paragraph here.", "structuredContent": null, "title": "My Project Brief", "accessInfo": "Read-only drive access..." } Structured Response (?format=structured)
Response 200 OK
{ "plainText": null, "structuredContent": { "title": "My Project Brief", "body": { "content": [ { "paragraph": { "elements": [ { "textRun": { "content": "This is the document content.\n" } } ] } } ] } }, "title": "My Project Brief", "accessInfo": "Read-only drive access..." } Note
The
structuredContent field contains the raw Google Docs API response. See the Google Docs API documentation for the full schema.Response 404 Not Found
{ "error": "Document not found in Google Drive." } POST
/api/access/drive/docs/{fileId}/editBearer TokenEdit Document
Apply text editing operations to a Google Doc. Supports insert, append, and find-and-replace.
Required Operation
Requires
edit_doc_content permission. Max request size: 5 MB. Max operations: 100 per request.Operation Types
| Operation | Required Fields | Description |
|---|---|---|
| insertText | text, index | Insert text at a character position (1 = start of document body) |
| appendText | text | Append text at the end of the document |
| replaceText | find, replace | Find and replace all occurrences of text |
Request Body Fields
| Field | Type | Required | Description |
|---|---|---|---|
| operations | array | Yes | List of edit operations (max 100) |
| operations[].type | string | Yes | insertText, appendText, or replaceText |
| operations[].text | string | For insert/append | Text content to insert or append |
| operations[].index | int | For insertText | Character position (1 = start of body). Default: 1 |
| operations[].find | string | For replaceText | Text to find |
| operations[].replace | string | For replaceText | Replacement text |
| operations[].matchCase | bool | No | Case-sensitive match for replaceText (default: true) |
Tip
insertText operations are automatically sorted by descending index to avoid position invalidation when multiple inserts target different positions.{ "operations": [ { "type": "insertText", "text": "Hello world\n", "index": 1 }, { "type": "appendText", "text": "\nNew paragraph at the end." }, { "type": "replaceText", "find": "old text", "replace": "new text", "matchCase": true } ] } Response 403 Forbidden
{ "success": false, "errorMessage": "Permission denied. The connected Google account does not have write access to this document.", "errorCode": "PERMISSION_DENIED" }