Insert text
insert_textInsert plain text into a Google Doc at a chosen position or append it to the end. Use precise indexes for targeted edits; newlines create paragraphs and the inserted text inherits the surrounding style.
Instructions
Inserts plain text at an index (UTF-16 code units; body content starts at index 1 — get indexes from read_document_text). Omit index to append at the end of the body (or of the segment when segment_id is set). Newlines in the text create new paragraphs; the text inherits the style at the insertion point — style it afterwards with style_text/style_paragraph. Every insert shifts all later indexes, so when making several edits, apply them from the END of the document backwards or re-read between edits. Returns the batchUpdate reply with the new revisionId.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The text to insert; \n starts a new paragraph. | |
| index | No | Insertion index (from read_document_text). Omit to append at the end. | |
| tab_id | No | Tab to target (from list_tabs). Omit for the first/only tab. | |
| segment_id | No | Header/footer/footnote segment id (from get_document). Omit for the document body. | |
| document_id | Yes | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. |