Actions40
- Create Bullets Request Actions
- Create Document Request Actions
- Create Headers & Footers Request Actions
- Create Images Request Actions
- Create Named Ranges Request Actions
- Create Tables Request Actions
- Create Tabs Request Actions
- Create Text Request Actions
- Send Request Actions
Create Text Request → Insert Text
AI-generatedSummary
Inserts text into a specified location within a Google Doc.
Inputs
- text (required) — Text to insert into the document.
- insertionLocation — Location Type. Determines whether to use an absolute index (location) or the end of a segment (endOfSegmentLocation). Defaults to location.
- index (required) — The zero-based index, in UTF-16 code units, relative to the beginning of the segment specified by segmentId. Required when insertionLocation is 'location'.
- segmentId — The ID of the header, footer, or footnote the location is in. An empty segment ID signifies the document's body. Required when insertionLocation is 'location'.
- tabId — The tab that the location is in. When omitted, the request is applied to the first tab. In a document containing a single tab: If provided, must match the singular tab's ID. If omitted, the request applies to the singular tab. In a document containing multiple tabs: If provided, the request applies to the specified tab. If omitted, the request applies to the first tab in the document.
Output shape
no body — success/failure only
The operation is part of a batch request system and does not return the updated document content or data items; it returns an empty body upon success or an error upon failure.
Examples
Example 1: Insert text at the very beginning of the document body.
Text: 'Hello World', Insertion Location: 'Location', Index: 0, Segment ID: '' (empty)
Example 2: Append text to the end of the document body.
Text: 'End of document', Insertion Location: 'End of Segment Location', Segment ID: '' (empty)
Example 3: Insert text into a specific header.
Text: 'Header Text', Insertion Location: 'Location', Index: 0, Segment ID: '