Modify Doc Text
modify_doc_textModifies text in a Google Doc by inserting or replacing content while optionally applying formatting such as bold, italic, or font changes in one operation.
Instructions
Modifies text in a Google Doc - can insert/replace text and/or apply formatting in a single operation.
TIP: To append text to the end of the document without calculating indices, set end_of_segment=true. This avoids index calculation errors.
For ordinary header/footer text, prefer update_doc_headers_footers. Only pass segment_id when you already have a real header/footer/footnote segment ID from inspect_doc_structure output. Do not guess IDs such as "kix.header" or "kix.footer".
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_google_email | Yes | User's Google email address | |
| document_id | Yes | ID of the document to update | |
| start_index | Yes | Start position for operation using Docs API indices from inspect_doc_structure. For the main body, 0 is also accepted as an alias for the first writable position. | |
| end_index | No | End position for text replacement/formatting (if not provided with text, text is inserted) | |
| text | No | New text to insert or replace with (optional - can format existing text without changing it) | |
| tab_id | No | Optional document tab ID to target | |
| segment_id | No | Optional header/footer/footnote segment ID to target | |
| end_of_segment | No | Insert text at the end of the targeted segment instead of start_index | |
| bold | No | Whether to make text bold (True/False/None to leave unchanged) | |
| italic | No | Whether to make text italic (True/False/None to leave unchanged) | |
| underline | No | Whether to underline text (True/False/None to leave unchanged) | |
| strikethrough | No | Whether to strike through text (True/False/None to leave unchanged) | |
| font_size | No | Font size in points | |
| font_family | No | Font family name (e.g., "Arial", "Times New Roman") | |
| font_weight | No | Font weight (100-900 in steps of 100; requires font_family) | |
| text_color | No | Foreground text color (#RRGGBB) | |
| background_color | No | Background/highlight color (#RRGGBB) | |
| link_url | No | Hyperlink URL (http/https) | |
| clear_link | No | Remove hyperlink from the target range | |
| baseline_offset | No | One of NONE, SUPERSCRIPT, SUBSCRIPT | |
| small_caps | No | Whether to apply small caps |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |