batch_update_doc
Execute multiple document operations in a single atomic batch to insert, format, or modify Google Docs content efficiently and avoid index calculation errors.
Instructions
Executes multiple low-level document operations in a single atomic batch update.
For normal header/footer text, prefer update_doc_headers_footers. Only use create_header_footer here for advanced section-break layouts.
RECOMMENDED WORKFLOW FOR BUILDING DOCUMENTS:
To avoid index calculation errors, build documents in phases:
PHASE 1 - INSERT ALL CONTENT (use end_of_segment=true, no index math): Append text, section breaks, and page breaks sequentially. Each operation appends to the end of the body. No index needed. Example batch: [ {"type": "insert_text", "end_of_segment": true, "text": "Report Title\n"}, {"type": "insert_text", "end_of_segment": true, "text": "\nExecutive Summary\n"}, {"type": "insert_text", "end_of_segment": true, "text": "Revenue grew 15%.\n"}, {"type": "insert_section_break", "end_of_segment": true, "section_type": "NEXT_PAGE"}, {"type": "insert_text", "end_of_segment": true, "text": "Detailed Analysis\n"} ]
PHASE 2 - CREATE HEADERS/FOOTERS (if needed): For normal header/footer text, use update_doc_headers_footers (it auto-creates if missing and writes the content for you). Only include create_header_footer operations in a batch when you are intentionally managing advanced section-break-specific layouts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_google_email | Yes | User's Google email address | |
| document_id | Yes | ID of the document to update | |
| operations | Yes | List of operation dicts. Each operation MUST have a 'type' field. All operations accept an optional 'tab_id' to target a specific tab. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |