Alpha: Document API is currently alpha and subject to breaking changes.
Summary
Insert content into the document. Two input shapes: legacy string-based (value + type) inserts inline content at a text position within an existing block; structural SDFragment (content) inserts one or more blocks as siblings relative to a BlockNodeAddress target. When target is omitted, content appends at the end of the document. Legacy mode supports text (default), markdown, and html content types via thetype field. Structural mode uses placement (before/after/insideStart/insideEnd) to position relative to the target block.
- Operation ID:
insert - API member path:
editor.doc.insert(...) - Mutates document:
yes - Idempotency:
non-idempotent - Supports tracked mode:
yes - Supports dry run:
yes - Deterministic target resolution:
yes
Expected result
Returns an SDMutationReceipt with applied status; resolution reports a TextAddress for legacy text insertion or a BlockNodeAddress for structural insertion. Receipt reports NO_OP if the insertion point is invalid or content is empty.Input fields
Variant 1 (target.kind=“text”)
| Field | Type | Required | Description |
|---|---|---|---|
target | TextAddress | no | TextAddress |
target.blockId | string | no | |
target.kind | "text" | no | Constant: "text" |
target.range | Range | no | Range |
target.range.end | integer | no | |
target.range.start | integer | no | |
type | enum | no | "text", "markdown", "html" |
value | string | yes |
Variant 2 (target.kind=“block”)
| Field | Type | Required | Description | |
|---|---|---|---|---|
content | object \ | object[] | yes | One of: object, object[] |
nestingPolicy | object | no | ||
nestingPolicy.tables | enum | no | "forbid", "allow" | |
placement | enum | no | "before", "after", "insideStart", "insideEnd" | |
target | BlockNodeAddress | no | BlockNodeAddress | |
target.kind | "block" | no | Constant: "block" | |
target.nodeId | string | no | ||
target.nodeType | enum | no | "paragraph", "heading", "listItem", "table", "tableRow", "tableCell", "tableOfContents", "image", "sdt" |
Example request
Output fields
Variant 1 (success=true)
| Field | Type | Required | Description | |
|---|---|---|---|---|
evaluatedRevision | object | no | ||
evaluatedRevision.after | string | no | ||
evaluatedRevision.before | string | no | ||
resolution | object | no | ||
resolution.range | TextMutationRange | no | TextMutationRange | |
resolution.range.from | integer | no | ||
resolution.range.to | integer | no | ||
resolution.selectionTarget | SelectionTarget | no | SelectionTarget | |
resolution.selectionTarget.end | SelectionPoint | no | SelectionPoint | |
resolution.selectionTarget.kind | "selection" | no | Constant: "selection" | |
resolution.selectionTarget.start | SelectionPoint | no | SelectionPoint | |
resolution.target | TextAddress \ | BlockNodeAddress | no | One of: TextAddress, BlockNodeAddress |
success | true | yes | Constant: true |
Variant 2 (success=false)
| Field | Type | Required | Description | |
|---|---|---|---|---|
evaluatedRevision | object | no | ||
evaluatedRevision.after | string | no | ||
evaluatedRevision.before | string | no | ||
failure | object | yes | ||
failure.code | enum | yes | "INVALID_TARGET", "NO_OP", "CAPABILITY_UNAVAILABLE", "UNSUPPORTED_ENVIRONMENT", "INVALID_NESTING", "INVALID_PLACEMENT", "INVALID_PAYLOAD", "CAPABILITY_UNSUPPORTED", "ADDRESS_STALE", "DUPLICATE_ID", "INVALID_CONTEXT", "RAW_MODE_REQUIRED", "PRESERVE_ONLY_VIOLATION", "INVALID_INPUT" | |
failure.details | any | no | ||
failure.message | string | yes | ||
resolution | object | no | ||
resolution.range | TextMutationRange | no | TextMutationRange | |
resolution.range.from | integer | no | ||
resolution.range.to | integer | no | ||
resolution.selectionTarget | SelectionTarget | no | SelectionTarget | |
resolution.selectionTarget.end | SelectionPoint | no | SelectionPoint | |
resolution.selectionTarget.kind | "selection" | no | Constant: "selection" | |
resolution.selectionTarget.start | SelectionPoint | no | SelectionPoint | |
resolution.target | TextAddress \ | BlockNodeAddress | no | One of: TextAddress, BlockNodeAddress |
success | false | yes | Constant: false |
Example response
Pre-apply throws
TARGET_NOT_FOUNDCAPABILITY_UNAVAILABLEINVALID_TARGETINVALID_INPUTADDRESS_STALEDUPLICATE_IDRAW_MODE_REQUIREDPRESERVE_ONLY_VIOLATIONCAPABILITY_UNSUPPORTED
Non-applied failure codes
INVALID_TARGETNO_OPCAPABILITY_UNAVAILABLEUNSUPPORTED_ENVIRONMENTINVALID_NESTINGINVALID_PLACEMENTINVALID_PAYLOADCAPABILITY_UNSUPPORTEDADDRESS_STALEDUPLICATE_IDINVALID_CONTEXTRAW_MODE_REQUIREDPRESERVE_ONLY_VIOLATIONINVALID_INPUT
Raw schemas
Raw input schema
Raw input schema
Raw output schema
Raw output schema
Raw success schema
Raw success schema
Raw failure schema
Raw failure schema

