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 Styled Text
AI-generatedSummary
Inserts styled text at a specific index in a Google Doc, applying custom text and paragraph formatting.
Inputs
- text (required) — Text to insert into the document.
- index (required) — Zero-based index in UTF-16 code units relative to the beginning of the segment specified by segmentId.
- segmentId — The ID of the header, footer, or footnote the location is in. An empty segment ID signifies the document's body.
- tabId — The ID of the tab that the location is in. If omitted, the request applies to the first tab.
- paragraphStyle — A collection of fields to configure paragraph alignment, borders, indentation, spacing, and named style types.
- textStyle — A collection of fields to configure text formatting including bold, font size, colors, links, and underlining.
Output shape
A single item containing the original input data.
The operation performs a batch update request to Google Docs. The index is relative to the segment ID; if segmentId is empty, the index is relative to the document body. Both text and paragraph style fields are optional; only specified fields are applied.
Examples
Example 1: Insert a paragraph of bold, centered text at the top of the document.
Text: 'Important Note', Index: 0, Paragraph Style: Center Alignment, Text Style: Bold
Example 2: Insert a subheading into a specific header.
Text: 'Subsection', Index: 10, Segment ID: 'header_1', Paragraph Style: Heading 2
Example 3: Add a footer note at a specific location in a document with multiple tabs.
Text: 'Page 1', Index: 5, Tab ID: 'tab-3', Segment ID: 'footer'