Google Docs Batch Update icon

Google Docs Batch Update

Build and send Google Docs batch update requests

Create Document Request → Update Document Style

AI-generated

Summary

Updates a document's style settings.

Inputs

  • background — The background of the document. Documents cannot have a transparent background color.
  • defaultFooterId — The ID of the default footer. If not set, there's no default footer.
  • defaultHeaderId — The ID of the default header. If not set, there's no default header.
  • documentFormat — Specifies document-level format settings, such as the document mode (pages vs pageless).
  • evenPageFooterId — The ID of the footer used only for even pages.
  • evenPageHeaderId — The ID of the header used only for even pages.
  • firstPageFooterId — The ID of the footer used only for the first page.
  • firstPageHeaderId — The ID of the header used only for the first page.
  • flipPageOrientation — Whether to flip the dimensions of the pageSize, which allows changing the page orientation between portrait and landscape.
  • marginBottom — The bottom page margin.
  • marginFooter — The amount of space between the bottom of the page and the contents of the footer.
  • marginHeader — The amount of space between the top of the page and the contents of the header.
  • marginLeft — The left page margin.
  • marginRight — The right page margin.
  • marginTop — The top page margin.
  • pageNumberStart — The page number from which to start counting.
  • pageSize — The size of a page in the document.
  • useCustomHeaderFooterMargins — Whether DocumentStyle marginHeader, SectionStyle marginHeader and DocumentStyle marginFooter, SectionStyle marginFooter are respected. When false, the default values in the Docs editor for header and footer margin is used.
  • useEvenPageHeaderFooter — Whether to use the even page header and footer.
  • useFirstPageHeaderFooter — Whether to use the first page header and footer.
  • fields — The fields that should be updated.
  • additionalFields — Additional fields to update (e.g., Tab ID).
  • tabId — The tab that the image to be replaced is in. When omitted, the request is applied to the first tab.

Output shape

a single document resource (JSON)

On success returns the updated document; on error returns an error object.

Examples

Example 1: Apply a red background and change the page size to A4.

Set background: #ff0000; pageSize: {height: 8.27, width: 11.69}; fields: background, pageSize

Example 2: Update margins and enable pageless mode.

Set marginTop: 1, marginBottom: 1, marginLeft: 1, marginRight: 1; documentFormat: PAGELESS; useCustomHeaderFooterMargins: true; fields: marginTop, marginBottom, marginLeft, marginRight, documentFormat, useCustomHeaderFooterMargins

Links

Discussion