Insert text into Google Doc
insert_textInsert text at a specific index in a Google Doc. Use indexes from get_document or find_text, with the body starting at index 1.
Instructions
Insert text at a specific index of a Google Doc. Get the index from get_document (the structure outline’s startIndex/endIndex) or find_text; the body starts at index 1 and the largest valid index is bodyEndIndex-1. To insert at the start of a paragraph use its startIndex. The inserted text takes the style of the neighbouring text, and "\n" creates new paragraphs. Inserting shifts every later index by insertedLength, so when making several index-based edits work from the end of the document backwards or re-read it with get_document. To add text at the end use append_text; to change existing wording use replace_text.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The text to insert. "\n" starts a new paragraph. | |
| index | Yes | A Google Docs index (UTF-16 offset). The body starts at index 1. Get exact indexes from get_document (structure) or find_text. | |
| documentId | Yes | The Google Docs document ID (the part between /d/ and /edit in the document URL). A full Google Docs URL is also accepted. |