Alpha: Document API is currently alpha and subject to breaking changes.
Summary
Replace content at a target position with new content. Accepts two input shapes: legacy string-based (text) or structural SDFragment (content). Structural mode replaces the target range with typed nodes (paragraphs, tables, images, etc.).- Operation ID:
replace - API member path:
editor.doc.replace(...) - Mutates document:
yes - Idempotency:
conditional - Supports tracked mode:
yes - Supports dry run:
yes - Deterministic target resolution:
yes
Expected result
Returns a TextMutationReceipt with applied status; receipt reports NO_OP if the target range already contains identical content.Input fields
| Field | Type | Required | Description |
|---|---|---|---|
target | TextAddress | yes | TextAddress |
target.blockId | string | yes | |
target.kind | "text" | yes | Constant: "text" |
target.range | Range | yes | Range |
target.range.end | integer | yes | |
target.range.start | integer | yes | |
text | string | yes |
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.requestedTarget | object | no | ||
resolution.requestedTarget.anchor | object | no | ||
resolution.requestedTarget.anchor.end | object | no | ||
resolution.requestedTarget.anchor.end.blockId | string | no | ||
resolution.requestedTarget.anchor.end.offset | integer | no | ||
resolution.requestedTarget.anchor.start | object | no | ||
resolution.requestedTarget.anchor.start.blockId | string | no | ||
resolution.requestedTarget.anchor.start.offset | integer | no | ||
resolution.requestedTarget.evaluatedRevision | string | no | ||
resolution.requestedTarget.kind | enum | no | "content", "inline", "annotation", "section" | |
resolution.requestedTarget.nodeId | string | no | ||
resolution.requestedTarget.path | string \ | integer[] | no | |
resolution.requestedTarget.stability | enum | no | "stable", "ephemeral" | |
resolution.target | object | no | ||
resolution.target.anchor | object | no | ||
resolution.target.anchor.end | object | no | ||
resolution.target.anchor.end.blockId | string | no | ||
resolution.target.anchor.end.offset | integer | no | ||
resolution.target.anchor.start | object | no | ||
resolution.target.anchor.start.blockId | string | no | ||
resolution.target.anchor.start.offset | integer | no | ||
resolution.target.evaluatedRevision | string | no | ||
resolution.target.kind | enum | no | "content", "inline", "annotation", "section" | |
resolution.target.nodeId | string | no | ||
resolution.target.path | string \ | integer[] | no | |
resolution.target.stability | enum | no | "stable", "ephemeral" | |
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", "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.requestedTarget | object | no | ||
resolution.requestedTarget.anchor | object | no | ||
resolution.requestedTarget.anchor.end | object | no | ||
resolution.requestedTarget.anchor.end.blockId | string | no | ||
resolution.requestedTarget.anchor.end.offset | integer | no | ||
resolution.requestedTarget.anchor.start | object | no | ||
resolution.requestedTarget.anchor.start.blockId | string | no | ||
resolution.requestedTarget.anchor.start.offset | integer | no | ||
resolution.requestedTarget.evaluatedRevision | string | no | ||
resolution.requestedTarget.kind | enum | no | "content", "inline", "annotation", "section" | |
resolution.requestedTarget.nodeId | string | no | ||
resolution.requestedTarget.path | string \ | integer[] | no | |
resolution.requestedTarget.stability | enum | no | "stable", "ephemeral" | |
resolution.target | object | no | ||
resolution.target.anchor | object | no | ||
resolution.target.anchor.end | object | no | ||
resolution.target.anchor.end.blockId | string | no | ||
resolution.target.anchor.end.offset | integer | no | ||
resolution.target.anchor.start | object | no | ||
resolution.target.anchor.start.blockId | string | no | ||
resolution.target.anchor.start.offset | integer | no | ||
resolution.target.evaluatedRevision | string | no | ||
resolution.target.kind | enum | no | "content", "inline", "annotation", "section" | |
resolution.target.nodeId | string | no | ||
resolution.target.path | string \ | integer[] | no | |
resolution.target.stability | enum | no | "stable", "ephemeral" | |
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_OPINVALID_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

