Retrieve Google Docs content with flexible optionsRequires Confirmation: NoParameters:
documentId (TEXT, Required): The ID of the Google Doc to retrieve. This is the string of characters in the URL after ‘document/d/’ when viewing the document
extractPlainTextOnly (BOOLEAN, Optional): When true, returns only the plain text content of the document without formatting
metadataOnly (BOOLEAN, Optional): When true, returns only the document metadata without the full content
includeTabsContent (BOOLEAN, Optional): When true, returns document with tabs structure populated. When false or unspecified, returns content from the first tab only
Output: Returns document content with the following structure:
documentId: Document ID
title: Document title
body: Document body content (if not metadata only)
plainText: Plain text content (if extractPlainTextOnly is true)
viewUrl: URL to view the document in Google Docs
retrievedAt: Timestamp when the document was retrieved
hasMultipleTabs: Whether the document has multiple tabs (if includeTabsContent is true)
tabs: Array of tab objects (if includeTabsContent is true)
metadata: Document metadata including creation time, modification time, owners, etc.
Search for Google Docs documents in your Google Drive using flexible filters such as document name, owner, modification date, folder, and sharing statusRequires Confirmation: NoParameters:
nameContains (TEXT, Optional): Only return documents whose name contains this text. Partial and case-insensitive matches are allowed
owner (TEXT, Optional): Only return documents owned by this email address. Leave blank to include documents from any owner
modifiedAfter (TEXT, Optional): Only return documents modified after this date (inclusive). Use ISO format (e.g., 2024-05-01)
modifiedBefore (TEXT, Optional): Only return documents modified before this date (exclusive). Use ISO format (e.g., 2024-06-01)
folder (TEXT, Optional): Only return documents located in this folder. Provide the folder ID. Leave blank for all folders
maximumResults (TEXT, Optional): The maximum number of documents to return. Leave blank to use the default (5000). The maximum allowed is 10,000
Output: Returns an array of document search results with the following structure:
Update a Google Docs documentRequires Confirmation: NoParameters:
documentId (TEXT, Required): The ID of the Google Doc to update. This is the string of characters in the URL after ‘document/d/’ when viewing the document, you can also retrieve it via the search file tool
markdownText (MULTI_LINE_TEXT, Optional): Optional raw Markdown to append and convert to native Google Docs formatting (supports headings #..######, lists -, *, 1., and bold text).
tab_id (TEXT, Optional): Optional: ID of the tab to target. If omitted, defaults to first tab.
tab_title (TEXT, Optional): Optional: Title of the tab to target (used if Tab ID is not provided).
anchor_text (TEXT, Optional): Optional: Insert content immediately after the paragraph that contains this text in the selected tab. If not provided, content is appended to the end of the tab.
anchor_match_case (BOOLEAN, Optional): Optional: When true, the anchor text match is case-sensitive.
actions (OBJECT, Optional): Available Actions:
Text Operations
Inserting Text
You can insert text into a document in two ways. The first approach uses a specific index position where you know content already exists. Provide the exact character index and the text string you want to insert. For example, inserting at index 5 would place your text after the fifth character in the document. The second and safer approach is to append text at the end of the current segment using the endOfSegmentLocation parameter along with your text string. This prevents index-related errors when you’re not certain about the document’s structure.Replacing Text
To find and replace text throughout the document, you need to specify what to find (the containsText parameter) and what to replace it with (the replaceText parameter). Within the containsText object, you must provide the text string to search for, and you can optionally set matchCase to true if you want case-sensitive replacement. This operation affects all matching occurrences throughout the document.Deleting Content
To remove content from a document, you must define a range with both startIndex and endIndex parameters. The operation will delete all content starting from the character at startIndex up to (but not including) the character at endIndex. Both indices must refer to existing content in the document.Formatting Operations
Styling Text
Text styling requires three key components: a range (with startIndex and endIndex identifying the text to format), a textStyle object containing the style properties you want to change, and a fields parameter listing which specific style properties to update. For example, you might specify bold, fontSize, or foregroundColor. Only the properties listed in the fields parameter will be changed, allowing for targeted formatting.Styling Paragraphs
Similar to text styling, paragraph formatting requires a range that encompasses the paragraphs to format, a paragraphStyle object with properties like alignment or indentation, and a fields parameter listing which paragraph style properties to update. The range must refer to entire paragraphs, not partial text within paragraphs.Document-Wide Styling
For document-level formatting, you need a documentStyle object containing the properties you want to change, such as background color or page size, and a fields parameter listing which document properties to update. For background color specifically, you must use a nested structure defining the RGB color values. This operation affects the entire document’s appearance.List Operations
Creating Bullet or Numbered Lists
To convert existing paragraphs into a list, you need a range (with startIndex and endIndex) that covers all paragraphs you want to include, and a bulletPreset parameter defining the list style. Available presets include disc/circle/square bullets, checkbox bullets, decimal/alphabetical/Roman numeral numbering, and various combinations with different nesting styles. The range must include only complete paragraphs, and text should be inserted before applying list formatting.Removing List Formatting
To convert bulleted or numbered paragraphs back to regular paragraphs, specify a range (with startIndex and endIndex) covering the list items you want to modify. This operation removes all bullet or numbering formatting while preserving the paragraph text and other formatting.Structural Elements
Creating Tables
To insert a table, you need to specify the number of rows and columns (both must be at least 1) and the endOfSegmentLocation where the table should be placed. After creating a table, you should retrieve the document structure to get the indices for individual cells before attempting to add content or styling to those cells.Inserting Table Rows
To insert a new row in a table, specify a tableCellLocation with the table’s start index and the row/column indices of a reference cell. Use insertBelow to control whether the row is inserted above or below the reference cell.Inserting Table Columns
To insert a new column in a table, specify a tableCellLocation with the table’s start index and the row/column indices of a reference cell. Use insertRight to control whether the column is inserted to the left or right of the reference cell.Deleting Table Rows
To delete rows from a table, provide the tableRowIndex (0-based index of the row to delete) and the tableStartLocation with the index of where the table begins in the document.Deleting Table Columns
To delete columns from a table, provide the tableColumnIndex (0-based index of the column to delete) and the tableStartLocation with the index of where the table begins in the document.Inserting Images
Image insertion requires a location index where the image should appear, a URI pointing to the image source, and an objectSize parameter with width and height dimensions. The dimensions should include both magnitude (numerical value) and unit (such as “pt” for points). Images can be inserted at any valid index within the document.Adding Page Breaks
To insert a page break, simply specify a location index where the break should occur. The index must refer to a valid position within existing document content, typically at the end of a paragraph.Creating Headers
To add a header to your document, specify the type as either “DEFAULT” (appearing on most pages), “FIRST_PAGE” (only on the first page), or “EVEN_PAGE” (only on even-numbered pages). After creating a header, you’ll need to retrieve the document to get the header’s ID before you can add content to it.Creating Footers
Footer creation works identically to headers. Specify the type as “DEFAULT”, “FIRST_PAGE”, or “EVEN_PAGE” to determine where the footer appears. As with headers, you’ll need to retrieve the document after creation to get the footer’s ID for adding content.Adding Footnotes
To insert a footnote, provide a location index where the footnote reference should appear in the main text. The footnote will be created with empty content, which you can populate in a subsequent operation after retrieving the document structure.Reference Operations
Creating Named Ranges
A named range allows you to mark a section of text for easy reference later. You need to provide a descriptive name for the range and the startIndex and endIndex parameters that define the range boundaries. After creating a named range, you’ll need to retrieve the document to get the generated range ID for future operations targeting that range.Each of these operations can be combined in a batch update request to efficiently make multiple changes to a document in a single API call. However, some operations have dependencies—for example, you should insert text before formatting it, create tables before adding content to cells, and create headers or footers before populating them with text.Output: Returns confirmation of the document update