# insert

> Insert content into the document. Two input shapes: text-based (value + type) inserts inline content at a SelectionTarget or ref position within an existing block; structural SDFragment (content) inserts one or more blocks as siblings relative to a BlockNodeAddress target. When target/ref is omitted, content appends at the end of the document. Text mode supports text (default), markdown, and html content types via the `type` field. Rich markdown/html and structural modes use `placement` (before/after/insideStart/insideEnd) to position relative to a block target.



- Member path: `doc.insert(…)`
- Mutates document: yes
- Idempotency: `non-idempotent`
- Supports tracked mode: yes
- Supports dry run: yes

## Expected result

Returns an SDMutationReceipt with applied status; resolution reports the resolved insertion point/target. Created visible text and structural blocks are reported through effects.insertedText and effects.insertedBlocks when available. Receipt reports NO_OP if the insertion point is invalid or content is empty.

## Input schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {
    "SelectionTarget": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "selection"
        },
        "start": {
          "$ref": "#/$defs/SelectionPoint"
        },
        "end": {
          "$ref": "#/$defs/SelectionPoint"
        },
        "story": {
          "$ref": "#/$defs/StoryLocator"
        },
        "coordinateSpace": {
          "$ref": "#/$defs/TextCoordinateSpace"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "start",
        "end"
      ]
    },
    "SelectionPoint": {
      "description": "A point in the document. Use {kind:'text', blockId, offset} for character positions or {kind:'nodeEdge', node:{kind:'block', nodeType, nodeId}, edge:'before'|'after'} for block boundaries.",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "text"
            },
            "blockId": {
              "type": "string"
            },
            "offset": {
              "type": "integer",
              "minimum": 0
            },
            "story": {
              "$ref": "#/$defs/StoryLocator"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "blockId",
            "offset"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "nodeEdge"
            },
            "node": {
              "$ref": "#/$defs/SelectionEdgeNodeAddress"
            },
            "edge": {
              "enum": [
                "before",
                "after"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "node",
            "edge"
          ]
        }
      ]
    },
    "StoryLocator": {
      "description": "Story scope. Defaults to document body when omitted. Use {kind:'story', storyType:'body'} for body, or other storyType values for headers, footers, footnotes, endnotes.",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "body"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "headerFooterSlot"
            },
            "section": {
              "$ref": "#/$defs/SectionAddress"
            },
            "headerFooterKind": {
              "enum": [
                "header",
                "footer"
              ]
            },
            "variant": {
              "enum": [
                "default",
                "first",
                "even"
              ]
            },
            "resolution": {
              "enum": [
                "effective",
                "explicit"
              ]
            },
            "onWrite": {
              "enum": [
                "materializeIfInherited",
                "editResolvedPart",
                "error"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "section",
            "headerFooterKind",
            "variant"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "headerFooterPart"
            },
            "refId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "refId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "footnote"
            },
            "noteId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "noteId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "endnote"
            },
            "noteId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "noteId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "textbox"
            },
            "textboxId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "textboxId"
          ]
        }
      ]
    },
    "SectionAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "section"
        },
        "sectionId": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "sectionId"
      ]
    },
    "SelectionEdgeNodeAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "block"
        },
        "nodeType": {
          "enum": [
            "paragraph",
            "heading",
            "table",
            "tableOfContents",
            "sdt",
            "image"
          ]
        },
        "nodeId": {
          "type": "string"
        },
        "story": {
          "$ref": "#/$defs/StoryLocator"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "nodeType",
        "nodeId"
      ]
    },
    "TextCoordinateSpace": {
      "enum": [
        "visible",
        "tracked"
      ]
    },
    "BlockNodeAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "block"
        },
        "nodeType": {
          "enum": [
            "paragraph",
            "heading",
            "listItem",
            "table",
            "tableRow",
            "tableCell",
            "tableOfContents",
            "image",
            "sdt"
          ]
        },
        "nodeId": {
          "type": "string"
        },
        "story": {
          "$ref": "#/$defs/StoryLocator"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "nodeType",
        "nodeId"
      ]
    }
  },
  "oneOf": [
    {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "target": {
              "$ref": "#/$defs/SelectionTarget",
              "description": "Selection target: {kind:'selection', start:{kind:'text', blockId, offset}, end:{kind:'text', blockId, offset}}."
            },
            "in": {
              "$ref": "#/$defs/StoryLocator"
            },
            "value": {
              "type": "string",
              "description": "Text content to insert."
            },
            "type": {
              "const": "text",
              "description": "Plain-text content format. Omit for the same 'text' default."
            }
          },
          "additionalProperties": false,
          "required": [
            "target",
            "value"
          ]
        },
        {
          "type": "object",
          "properties": {
            "ref": {
              "type": "string",
              "description": "Handle ref from superdoc_search result (pass handle.ref value directly). Preferred over building a target object."
            },
            "in": {
              "$ref": "#/$defs/StoryLocator"
            },
            "value": {
              "type": "string",
              "description": "Text content to insert."
            },
            "type": {
              "const": "text",
              "description": "Plain-text content format. Omit for the same 'text' default."
            }
          },
          "additionalProperties": false,
          "required": [
            "ref",
            "value"
          ]
        },
        {
          "type": "object",
          "properties": {
            "in": {
              "$ref": "#/$defs/StoryLocator"
            },
            "value": {
              "type": "string",
              "description": "Text content to insert."
            },
            "type": {
              "const": "text",
              "description": "Plain-text content format. Omit for the same 'text' default."
            }
          },
          "additionalProperties": false,
          "required": [
            "value"
          ]
        }
      ]
    },
    {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "in": {
              "$ref": "#/$defs/StoryLocator"
            },
            "target": {
              "oneOf": [
                {
                  "$ref": "#/$defs/SelectionTarget"
                },
                {
                  "$ref": "#/$defs/BlockNodeAddress"
                }
              ]
            },
            "value": {
              "type": "string",
              "description": "HTML or Markdown content to convert and insert."
            },
            "type": {
              "enum": [
                "markdown",
                "html"
              ]
            },
            "placement": {
              "enum": [
                "before",
                "after",
                "insideStart",
                "insideEnd"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "target",
            "value",
            "type"
          ]
        },
        {
          "type": "object",
          "properties": {
            "in": {
              "$ref": "#/$defs/StoryLocator"
            },
            "ref": {
              "type": "string",
              "minLength": 1
            },
            "value": {
              "type": "string",
              "description": "HTML or Markdown content to convert and insert."
            },
            "type": {
              "enum": [
                "markdown",
                "html"
              ]
            },
            "placement": {
              "enum": [
                "before",
                "after",
                "insideStart",
                "insideEnd"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "ref",
            "value",
            "type"
          ]
        },
        {
          "type": "object",
          "properties": {
            "in": {
              "$ref": "#/$defs/StoryLocator"
            },
            "value": {
              "type": "string",
              "description": "HTML or Markdown content to convert and insert."
            },
            "type": {
              "enum": [
                "markdown",
                "html"
              ]
            },
            "placement": {
              "enum": [
                "before",
                "after",
                "insideStart",
                "insideEnd"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "value",
            "type"
          ]
        }
      ]
    },
    {
      "type": "object",
      "properties": {
        "in": {
          "$ref": "#/$defs/StoryLocator"
        },
        "target": {
          "$ref": "#/$defs/BlockNodeAddress",
          "description": "Block address for structural insertion: {kind:'block', nodeType:'...', nodeId:'...'}."
        },
        "content": {
          "oneOf": [
            {
              "type": "object"
            },
            {
              "type": "array",
              "items": {
                "type": "object"
              }
            }
          ],
          "description": "Document fragment to insert (structured content)."
        },
        "placement": {
          "enum": [
            "before",
            "after",
            "insideStart",
            "insideEnd"
          ],
          "description": "Where to place content relative to target: 'before', 'after', 'insideStart', or 'insideEnd'."
        },
        "nestingPolicy": {
          "type": "object",
          "properties": {
            "tables": {
              "enum": [
                "forbid",
                "allow"
              ]
            }
          },
          "additionalProperties": false,
          "description": "Controls nesting behavior. tables: 'allow' permits inserting tables inside other tables."
        }
      },
      "additionalProperties": false,
      "required": [
        "content"
      ]
    }
  ]
}
```

## Output schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {
    "TextAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "text"
        },
        "blockId": {
          "type": "string"
        },
        "range": {
          "$ref": "#/$defs/Range"
        },
        "story": {
          "$ref": "#/$defs/StoryLocator"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "blockId",
        "range"
      ]
    },
    "Range": {
      "type": "object",
      "properties": {
        "start": {
          "type": "integer"
        },
        "end": {
          "type": "integer"
        }
      },
      "additionalProperties": false,
      "required": [
        "start",
        "end"
      ]
    },
    "StoryLocator": {
      "description": "Story scope. Defaults to document body when omitted. Use {kind:'story', storyType:'body'} for body, or other storyType values for headers, footers, footnotes, endnotes.",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "body"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "headerFooterSlot"
            },
            "section": {
              "$ref": "#/$defs/SectionAddress"
            },
            "headerFooterKind": {
              "enum": [
                "header",
                "footer"
              ]
            },
            "variant": {
              "enum": [
                "default",
                "first",
                "even"
              ]
            },
            "resolution": {
              "enum": [
                "effective",
                "explicit"
              ]
            },
            "onWrite": {
              "enum": [
                "materializeIfInherited",
                "editResolvedPart",
                "error"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "section",
            "headerFooterKind",
            "variant"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "headerFooterPart"
            },
            "refId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "refId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "footnote"
            },
            "noteId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "noteId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "endnote"
            },
            "noteId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "noteId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "textbox"
            },
            "textboxId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "textboxId"
          ]
        }
      ]
    },
    "SectionAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "section"
        },
        "sectionId": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "sectionId"
      ]
    },
    "BlockNodeAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "block"
        },
        "nodeType": {
          "enum": [
            "paragraph",
            "heading",
            "listItem",
            "table",
            "tableRow",
            "tableCell",
            "tableOfContents",
            "image",
            "sdt"
          ]
        },
        "nodeId": {
          "type": "string"
        },
        "story": {
          "$ref": "#/$defs/StoryLocator"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "nodeType",
        "nodeId"
      ]
    },
    "TextMutationRange": {
      "type": "object",
      "properties": {
        "from": {
          "type": "integer"
        },
        "to": {
          "type": "integer"
        }
      },
      "additionalProperties": false,
      "required": [
        "from",
        "to"
      ]
    },
    "SelectionTarget": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "selection"
        },
        "start": {
          "$ref": "#/$defs/SelectionPoint"
        },
        "end": {
          "$ref": "#/$defs/SelectionPoint"
        },
        "story": {
          "$ref": "#/$defs/StoryLocator"
        },
        "coordinateSpace": {
          "$ref": "#/$defs/TextCoordinateSpace"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "start",
        "end"
      ]
    },
    "SelectionPoint": {
      "description": "A point in the document. Use {kind:'text', blockId, offset} for character positions or {kind:'nodeEdge', node:{kind:'block', nodeType, nodeId}, edge:'before'|'after'} for block boundaries.",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "text"
            },
            "blockId": {
              "type": "string"
            },
            "offset": {
              "type": "integer",
              "minimum": 0
            },
            "story": {
              "$ref": "#/$defs/StoryLocator"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "blockId",
            "offset"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "nodeEdge"
            },
            "node": {
              "$ref": "#/$defs/SelectionEdgeNodeAddress"
            },
            "edge": {
              "enum": [
                "before",
                "after"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "node",
            "edge"
          ]
        }
      ]
    },
    "SelectionEdgeNodeAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "block"
        },
        "nodeType": {
          "enum": [
            "paragraph",
            "heading",
            "table",
            "tableOfContents",
            "sdt",
            "image"
          ]
        },
        "nodeId": {
          "type": "string"
        },
        "story": {
          "$ref": "#/$defs/StoryLocator"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "nodeType",
        "nodeId"
      ]
    },
    "TextCoordinateSpace": {
      "enum": [
        "visible",
        "tracked"
      ]
    },
    "EntityAddress": {
      "oneOf": [
        {
          "$ref": "#/$defs/CommentAddress"
        },
        {
          "$ref": "#/$defs/TrackedChangeAddress"
        }
      ]
    },
    "CommentAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "entity"
        },
        "entityType": {
          "const": "comment"
        },
        "entityId": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "entityType",
        "entityId"
      ]
    },
    "TrackedChangeAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "entity"
        },
        "entityType": {
          "const": "trackedChange"
        },
        "entityId": {
          "type": "string"
        },
        "story": {
          "$ref": "#/$defs/StoryLocator"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "entityType",
        "entityId"
      ]
    },
    "AffectedRef": {
      "oneOf": [
        {
          "$ref": "#/$defs/TextAddress"
        },
        {
          "$ref": "#/$defs/BookmarkAddress"
        },
        {
          "$ref": "#/$defs/CommentAddress"
        },
        {
          "$ref": "#/$defs/TrackedChangeAddress"
        },
        {
          "$ref": "#/$defs/BlockNavigationAddress"
        }
      ]
    },
    "BookmarkAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "entity"
        },
        "entityType": {
          "const": "bookmark"
        },
        "name": {
          "type": "string"
        },
        "story": {
          "$ref": "#/$defs/StoryLocator"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "entityType",
        "name"
      ]
    },
    "BlockNavigationAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "block"
        },
        "nodeId": {
          "type": "string"
        },
        "nodeType": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "nodeId"
      ]
    },
    "AffectedRefRemapping": {
      "type": "object",
      "properties": {
        "from": {
          "$ref": "#/$defs/AffectedRef"
        },
        "to": {
          "$ref": "#/$defs/AffectedRef"
        }
      },
      "additionalProperties": false,
      "required": [
        "from",
        "to"
      ]
    },
    "TextRangeShift": {
      "type": "object",
      "properties": {
        "story": {
          "$ref": "#/$defs/StoryLocator"
        },
        "atChar": {
          "type": "integer"
        },
        "blockId": {
          "type": "string"
        },
        "atCharInBlock": {
          "type": "integer"
        },
        "delta": {
          "type": "integer"
        }
      },
      "additionalProperties": false,
      "required": [
        "story",
        "atChar",
        "delta"
      ]
    },
    "ReviewWarning": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "feature": {
          "enum": [
            "comments",
            "trackedChanges"
          ]
        },
        "severity": {
          "const": "warning"
        },
        "affectedObjectId": {
          "type": "string"
        },
        "affectedPartUri": {
          "type": "string"
        },
        "canProceed": {
          "type": "boolean"
        }
      },
      "additionalProperties": false,
      "required": [
        "code",
        "message",
        "feature",
        "severity",
        "canProceed"
      ]
    },
    "ReceiptEffects": {
      "type": "object",
      "properties": {
        "insertedText": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/TextMutationEffect"
          }
        },
        "insertedBlocks": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/BlockMutationEffect"
          }
        }
      },
      "additionalProperties": false
    },
    "TextMutationEffect": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "insertedText"
        },
        "sourcePath": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "integer"
              }
            ]
          }
        },
        "target": {
          "$ref": "#/$defs/TextAddress"
        },
        "selectionTarget": {
          "$ref": "#/$defs/SelectionTarget"
        },
        "text": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "target",
        "selectionTarget",
        "text"
      ]
    },
    "BlockMutationEffect": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "insertedBlock"
        },
        "sourcePath": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "integer"
              }
            ]
          }
        },
        "target": {
          "$ref": "#/$defs/BlockNodeAddress"
        },
        "insertedText": {
          "$ref": "#/$defs/TextMutationEffect"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "target"
      ]
    }
  },
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "success": {
          "const": true
        },
        "outcome": {
          "enum": [
            "preserved",
            "preserved-with-warnings",
            "simplified",
            "rejected",
            "no-op",
            "invalid-target",
            "outdated"
          ]
        },
        "resolution": {
          "type": "object",
          "properties": {
            "target": {
              "oneOf": [
                {
                  "$ref": "#/$defs/TextAddress"
                },
                {
                  "$ref": "#/$defs/BlockNodeAddress"
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "const": "story"
                    },
                    "storyType": {
                      "const": "body"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "kind",
                    "storyType"
                  ]
                }
              ]
            },
            "range": {
              "$ref": "#/$defs/TextMutationRange"
            },
            "selectionTarget": {
              "$ref": "#/$defs/SelectionTarget"
            }
          },
          "additionalProperties": false,
          "required": [
            "target",
            "range"
          ]
        },
        "id": {
          "type": "string"
        },
        "inserted": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/EntityAddress"
          }
        },
        "updated": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/EntityAddress"
          }
        },
        "removed": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/EntityAddress"
          }
        },
        "invalidatedRefs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AffectedRef"
          }
        },
        "remappedRefs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AffectedRefRemapping"
          }
        },
        "affectedStories": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/StoryLocator"
          }
        },
        "textRangeShifts": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/TextRangeShift"
          }
        },
        "txId": {
          "type": "string"
        },
        "warnings": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ReviewWarning"
          }
        },
        "effects": {
          "$ref": "#/$defs/ReceiptEffects"
        },
        "evaluatedRevision": {
          "type": "object",
          "properties": {
            "before": {
              "type": "string"
            },
            "after": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "before",
            "after"
          ]
        },
        "conversion": {
          "type": "object",
          "properties": {
            "format": {
              "enum": [
                "html",
                "markdown"
              ]
            },
            "lossy": {
              "type": "boolean"
            },
            "diagnostics": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "code": {
                    "enum": [
                      "conversion-normalized-construct",
                      "conversion-unsupported-construct",
                      "conversion-dropped-style",
                      "conversion-unsafe-content",
                      "conversion-unsafe-url",
                      "conversion-source-limit-exceeded",
                      "conversion-depth-limit-exceeded",
                      "conversion-malformed-input",
                      "conversion-empty-result"
                    ]
                  },
                  "severity": {
                    "enum": [
                      "error",
                      "warning",
                      "info"
                    ]
                  },
                  "message": {
                    "type": "string"
                  },
                  "path": {
                    "type": "array",
                    "items": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "integer"
                        }
                      ]
                    }
                  },
                  "construct": {
                    "enum": [
                      "document",
                      "source",
                      "text",
                      "paragraph",
                      "emptyParagraph",
                      "softBreak",
                      "lineBreak",
                      "heading",
                      "bold",
                      "italic",
                      "underline",
                      "strike",
                      "hyperlink",
                      "list",
                      "table",
                      "tableHeader",
                      "colSpan",
                      "rowSpan",
                      "horizontalRule",
                      "inlineCode",
                      "codeBlock",
                      "blockquote",
                      "taskList",
                      "image",
                      "footnote",
                      "rawHtml",
                      "unknownWrapper",
                      "script",
                      "style",
                      "eventHandler"
                    ]
                  },
                  "disposition": {
                    "enum": [
                      "preserved",
                      "normalized",
                      "downgraded",
                      "dropped",
                      "rejected"
                    ]
                  },
                  "lossy": {
                    "type": "boolean"
                  },
                  "source": {
                    "type": "object",
                    "properties": {
                      "format": {
                        "enum": [
                          "html",
                          "markdown"
                        ]
                      },
                      "range": {
                        "type": "object",
                        "properties": {
                          "startOffset": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "endOffset": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "startLine": {
                            "type": "integer",
                            "minimum": 1
                          },
                          "startColumn": {
                            "type": "integer",
                            "minimum": 1
                          },
                          "endLine": {
                            "type": "integer",
                            "minimum": 1
                          },
                          "endColumn": {
                            "type": "integer",
                            "minimum": 1
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "startOffset",
                          "endOffset"
                        ]
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "format"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "code",
                  "severity",
                  "message",
                  "construct",
                  "disposition",
                  "lossy",
                  "source"
                ]
              }
            }
          },
          "additionalProperties": false,
          "required": [
            "format",
            "lossy",
            "diagnostics"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "success"
      ]
    },
    {
      "type": "object",
      "properties": {
        "success": {
          "const": false
        },
        "outcome": {
          "enum": [
            "preserved",
            "preserved-with-warnings",
            "simplified",
            "rejected",
            "no-op",
            "invalid-target",
            "outdated"
          ]
        },
        "failure": {
          "type": "object",
          "properties": {
            "code": {
              "enum": [
                "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",
                "TARGET_NOT_FOUND",
                "PRECONDITION_FAILED",
                "REVISION_MISMATCH",
                "CHECK_MISMATCH",
                "INTERNAL_ERROR"
              ]
            },
            "message": {
              "type": "string"
            },
            "path": {
              "type": "array",
              "items": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "integer"
                  }
                ]
              }
            },
            "target": {
              "oneOf": [
                {
                  "$ref": "#/$defs/BlockNodeAddress"
                },
                {
                  "$ref": "#/$defs/TextAddress"
                },
                {
                  "$ref": "#/$defs/SelectionTarget"
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "const": "story"
                    },
                    "storyType": {
                      "const": "body"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "kind",
                    "storyType"
                  ]
                }
              ]
            },
            "details": {}
          },
          "additionalProperties": false,
          "required": [
            "code",
            "message"
          ]
        },
        "resolution": {
          "type": "object",
          "properties": {
            "target": {
              "oneOf": [
                {
                  "$ref": "#/$defs/TextAddress"
                },
                {
                  "$ref": "#/$defs/BlockNodeAddress"
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "const": "story"
                    },
                    "storyType": {
                      "const": "body"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "kind",
                    "storyType"
                  ]
                }
              ]
            },
            "range": {
              "$ref": "#/$defs/TextMutationRange"
            },
            "selectionTarget": {
              "$ref": "#/$defs/SelectionTarget"
            }
          },
          "additionalProperties": false,
          "required": [
            "target",
            "range"
          ]
        },
        "evaluatedRevision": {
          "type": "object",
          "properties": {
            "before": {
              "type": "string"
            },
            "after": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "before",
            "after"
          ]
        },
        "conversion": {
          "type": "object",
          "properties": {
            "format": {
              "enum": [
                "html",
                "markdown"
              ]
            },
            "lossy": {
              "type": "boolean"
            },
            "diagnostics": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "code": {
                    "enum": [
                      "conversion-normalized-construct",
                      "conversion-unsupported-construct",
                      "conversion-dropped-style",
                      "conversion-unsafe-content",
                      "conversion-unsafe-url",
                      "conversion-source-limit-exceeded",
                      "conversion-depth-limit-exceeded",
                      "conversion-malformed-input",
                      "conversion-empty-result"
                    ]
                  },
                  "severity": {
                    "enum": [
                      "error",
                      "warning",
                      "info"
                    ]
                  },
                  "message": {
                    "type": "string"
                  },
                  "path": {
                    "type": "array",
                    "items": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "integer"
                        }
                      ]
                    }
                  },
                  "construct": {
                    "enum": [
                      "document",
                      "source",
                      "text",
                      "paragraph",
                      "emptyParagraph",
                      "softBreak",
                      "lineBreak",
                      "heading",
                      "bold",
                      "italic",
                      "underline",
                      "strike",
                      "hyperlink",
                      "list",
                      "table",
                      "tableHeader",
                      "colSpan",
                      "rowSpan",
                      "horizontalRule",
                      "inlineCode",
                      "codeBlock",
                      "blockquote",
                      "taskList",
                      "image",
                      "footnote",
                      "rawHtml",
                      "unknownWrapper",
                      "script",
                      "style",
                      "eventHandler"
                    ]
                  },
                  "disposition": {
                    "enum": [
                      "preserved",
                      "normalized",
                      "downgraded",
                      "dropped",
                      "rejected"
                    ]
                  },
                  "lossy": {
                    "type": "boolean"
                  },
                  "source": {
                    "type": "object",
                    "properties": {
                      "format": {
                        "enum": [
                          "html",
                          "markdown"
                        ]
                      },
                      "range": {
                        "type": "object",
                        "properties": {
                          "startOffset": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "endOffset": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "startLine": {
                            "type": "integer",
                            "minimum": 1
                          },
                          "startColumn": {
                            "type": "integer",
                            "minimum": 1
                          },
                          "endLine": {
                            "type": "integer",
                            "minimum": 1
                          },
                          "endColumn": {
                            "type": "integer",
                            "minimum": 1
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "startOffset",
                          "endOffset"
                        ]
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "format"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "code",
                  "severity",
                  "message",
                  "construct",
                  "disposition",
                  "lossy",
                  "source"
                ]
              }
            }
          },
          "additionalProperties": false,
          "required": [
            "format",
            "lossy",
            "diagnostics"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "success",
        "failure"
      ]
    }
  ]
}
```

## Pre-apply throws

- `TARGET_NOT_FOUND`
- `CAPABILITY_UNAVAILABLE`
- `INVALID_TARGET`
- `INVALID_INPUT`
- `ADDRESS_STALE`
- `DUPLICATE_ID`
- `RAW_MODE_REQUIRED`
- `PRESERVE_ONLY_VIOLATION`
- `CAPABILITY_UNSUPPORTED`
- `STORY_NOT_FOUND`
- `STORY_MISMATCH`
- `STORY_NOT_SUPPORTED`
- `CROSS_STORY_PLAN`
- `MATERIALIZATION_FAILED`

## Non-applied receipt codes

- `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`
- `TARGET_NOT_FOUND`
- `PRECONDITION_FAILED`
- `REVISION_MISMATCH`
- `CHECK_MISMATCH`
- `INTERNAL_ERROR`

