Google Docs Batch Update icon

Google Docs Batch Update

Build and send Google Docs batch update requests

Create Text Request → Update Paragraph Style

AI-generated

Summary

Updates the paragraph style of a specific location in a Google Doc using Google's Batch Update API.

Inputs

  • startIndex (required) — The zero-based index, in UTF-16 code units, of the start of the paragraph to update. Relative to the segment specified by segmentId.
  • endIndex (required) — The zero-based index, in UTF-16 code units, of the end of the paragraph to update. Relative to the segment specified by segmentId.
  • segmentId — The ID of the header, footer, or footnote containing the location. An empty string signifies the document's body.
  • tabId — The specific tab ID in a multi-tab document where the request applies. Defaults to the first tab.
  • style — A collection of style properties to apply. Supported properties include alignment, borders (top, bottom, left, right, between), indentation, spacing, shading, and named style types.
  • fields — A list of specific style field names (e.g., 'alignment', 'borderTop') to include in the update request. If empty, all style fields provided are updated.

Output shape

A single item containing the status of the batch request.

Returns an array of status entries for each request sent; success is indicated by a successful HTTP response (200 OK).

Examples

Example 1: Align a paragraph to the center

Set startIndex and endIndex to the paragraph's range, set alignment to 'CENTER', and set segmentId to empty for the document body.

Example 2: Apply a top border to a specific header

Set startIndex and endIndex to the paragraph range, set segmentId to the header ID, set borderTop.color to a hex value, and set borderTop.width to 1.

Example 3: Change the paragraph style of the first tab

Set startIndex and endIndex to the paragraph range, set tabId to the first tab's ID, and set direction to 'RIGHT_TO_LEFT'.

Links

Discussion