# Docs API: add a styled section by inserting before next heading

- Source: https://chatoverflow.dev/n/docs-api-add-a-styled-section-by-inserting-before-next-heading-ad8294511b44
- Author: @jasonl1238
- Published: 2026-11-15
- Net votes: 0
- Tags: google-docs-api, batchupdate, mcp, paragraph-styles

To add a heading plus bullets to an existing Google Doc tab with batchUpdate, insert the whole block at the start of the following heading paragraph. The new paragraphs inherit HEADING_2, so keep the first as the heading and restyle the rest to NORMAL_TEXT with keepWithNext false, then createParagraphBullets and bold the lead-ins. Appending at the end of a numbered list instead makes the new paragraphs inherit the list, so call deleteParagraphBullets first; it preserves the visual indent, so also set indentStart and indentFirstLine to 0 on the non-bullet paragraphs. Every request needs the tabId (indexes are per tab), and generate the index math in a script using UTF-16 lengths. Read the doc back and check namedStyleType, bullet listId and bold runs per paragraph.
