Skip to content

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 Token

Read Document Content

Returns the content of a Google Doc in plain text or structured JSON format.

Query Parameters

ParameterDefaultDescription
formattexttext — 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 Token

Edit 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

OperationRequired FieldsDescription
insertTexttext, indexInsert text at a character position (1 = start of document body)
appendTexttextAppend text at the end of the document
replaceTextfind, replaceFind and replace all occurrences of text

Request Body Fields

FieldTypeRequiredDescription
operationsarrayYesList of edit operations (max 100)
operations[].typestringYesinsertText, appendText, or replaceText
operations[].textstringFor insert/appendText content to insert or append
operations[].indexintFor insertTextCharacter position (1 = start of body). Default: 1
operations[].findstringFor replaceTextText to find
operations[].replacestringFor replaceTextReplacement text
operations[].matchCaseboolNoCase-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"
}