Table of contents blocks are managed automatically during Word document import and export. There are no commands to programmatically create or update a TOC.
All
Table of Contents extension
Display Word-generated tables of contents with heading hierarchy preservation.
Tables of contents imported from Word documents render as block elements containing the original TOC paragraphs and page references.

