Delete text from Google Doc
delete_textDelete a range of content from a Google Doc by index, with optional expectedText verification to guard against stale indexes.
Instructions
DESTRUCTIVE: delete the content in the index range [startIndex, endIndex) of a Google Doc (endIndex is exclusive). Get the indexes from get_document or find_text immediately before calling. Strongly recommended: pass expectedText with the exact text currently in that range (including any "\n" paragraph breaks); if it does not match, nothing is deleted and the current text is returned, which protects against stale indexes. The document’s final newline cannot be deleted (the maximum endIndex is bodyEndIndex-1). Deleting a paragraph break merges the two paragraphs; tables can only be deleted as a whole, although the text inside a cell can be deleted. Every later index shifts back by deletedLength. Deleted content can only be recovered from the Google Docs version history. To delete every occurrence of a phrase use replace_text with an empty replacementText.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endIndex | Yes | End of the range (exclusive); must be greater than startIndex. | |
| 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. | |
| startIndex | Yes | Start of the range (inclusive). Get exact indexes from get_document or find_text. | |
| expectedText | No | The exact text currently in [startIndex, endIndex). If given, the deletion is refused when the document text differs. |