Skip to main content
Alpha: Document API is currently alpha and subject to breaking changes.

Summary

Insert a new table of contents at the target position.
  • Operation ID: create.tableOfContents
  • API member path: editor.doc.create.tableOfContents(...)
  • Mutates document: yes
  • Idempotency: non-idempotent
  • Supports tracked mode: no
  • Supports dry run: yes
  • Deterministic target resolution: yes

Expected result

Returns a CreateTableOfContentsResult with the new TOC block address.

Input fields

FieldTypeRequiredDescription
atobject(kind=“documentStart”) \object(kind=“documentEnd”) \object(kind=“before”) \object(kind=“after”)noOne of: object(kind=“documentStart”), object(kind=“documentEnd”), object(kind=“before”), object(kind=“after”)
configobjectno

Example request

{
  "at": {
    "kind": "documentStart"
  },
  "config": {
    "outlineLevels": {
      "from": 0,
      "to": 10
    },
    "useAppliedOutlineLevel": true
  }
}

Output fields

No fields.

Example response

{
  "success": true,
  "toc": {
    "kind": "block",
    "nodeId": "node-def456",
    "nodeType": "tableOfContents"
  }
}

Pre-apply throws

  • INVALID_TARGET
  • TARGET_NOT_FOUND
  • CAPABILITY_UNAVAILABLE

Non-applied failure codes

  • NO_OP
  • INVALID_INSERTION_CONTEXT

Raw schemas

{
  "additionalProperties": false,
  "properties": {
    "at": {
      "oneOf": [
        {
          "additionalProperties": false,
          "properties": {
            "kind": {
              "const": "documentStart"
            }
          },
          "required": [
            "kind"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "kind": {
              "const": "documentEnd"
            }
          },
          "required": [
            "kind"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "kind": {
              "const": "before"
            },
            "target": {
              "$ref": "#/$defs/BlockNodeAddress"
            }
          },
          "required": [
            "kind",
            "target"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "kind": {
              "const": "after"
            },
            "target": {
              "$ref": "#/$defs/BlockNodeAddress"
            }
          },
          "required": [
            "kind",
            "target"
          ],
          "type": "object"
        }
      ]
    },
    "config": {
      "additionalProperties": false,
      "properties": {
        "hideInWebView": {
          "type": "boolean"
        },
        "hyperlinks": {
          "type": "boolean"
        },
        "omitPageNumberLevels": {
          "additionalProperties": false,
          "properties": {
            "from": {
              "type": "integer"
            },
            "to": {
              "type": "integer"
            }
          },
          "required": [
            "from",
            "to"
          ],
          "type": "object"
        },
        "outlineLevels": {
          "additionalProperties": false,
          "properties": {
            "from": {
              "type": "integer"
            },
            "to": {
              "type": "integer"
            }
          },
          "required": [
            "from",
            "to"
          ],
          "type": "object"
        },
        "separator": {
          "type": "string"
        },
        "useAppliedOutlineLevel": {
          "type": "boolean"
        }
      },
      "type": "object"
    }
  },
  "type": "object"
}
{
  "oneOf": [
    {
      "additionalProperties": false,
      "properties": {
        "success": {
          "const": true
        },
        "toc": {
          "additionalProperties": false,
          "properties": {
            "kind": {
              "const": "block"
            },
            "nodeId": {
              "type": "string"
            },
            "nodeType": {
              "const": "tableOfContents"
            }
          },
          "required": [
            "kind",
            "nodeType",
            "nodeId"
          ],
          "type": "object"
        }
      },
      "required": [
        "success",
        "toc"
      ],
      "type": "object"
    },
    {
      "additionalProperties": false,
      "properties": {
        "failure": {
          "additionalProperties": false,
          "properties": {
            "code": {
              "enum": [
                "NO_OP",
                "INVALID_TARGET",
                "TARGET_NOT_FOUND",
                "CAPABILITY_UNAVAILABLE",
                "INVALID_INSERTION_CONTEXT"
              ]
            },
            "details": {},
            "message": {
              "type": "string"
            }
          },
          "required": [
            "code",
            "message"
          ],
          "type": "object"
        },
        "success": {
          "const": false
        }
      },
      "required": [
        "success",
        "failure"
      ],
      "type": "object"
    }
  ]
}
{
  "additionalProperties": false,
  "properties": {
    "success": {
      "const": true
    },
    "toc": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "block"
        },
        "nodeId": {
          "type": "string"
        },
        "nodeType": {
          "const": "tableOfContents"
        }
      },
      "required": [
        "kind",
        "nodeType",
        "nodeId"
      ],
      "type": "object"
    }
  },
  "required": [
    "success",
    "toc"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "failure": {
      "additionalProperties": false,
      "properties": {
        "code": {
          "enum": [
            "NO_OP",
            "INVALID_TARGET",
            "TARGET_NOT_FOUND",
            "CAPABILITY_UNAVAILABLE",
            "INVALID_INSERTION_CONTEXT"
          ]
        },
        "details": {},
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "type": "object"
    },
    "success": {
      "const": false
    }
  },
  "required": [
    "success",
    "failure"
  ],
  "type": "object"
}