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

Summary

Delete a contiguous range of top-level blocks between two endpoints (inclusive). Both endpoints must be direct children of the document node. Supports dry-run preview.
  • Operation ID: blocks.deleteRange
  • API member path: editor.doc.blocks.deleteRange(...)
  • Mutates document: yes
  • Idempotency: conditional
  • Supports tracked mode: no
  • Supports dry run: yes
  • Deterministic target resolution: yes

Expected result

Returns a BlocksDeleteRangeResult with deletedCount, deletedBlocks array (each with ordinal, nodeId, nodeType, textPreview), before/after revision, and dryRun flag.

Input fields

FieldTypeRequiredDescription
endBlockNodeAddressyesBlockNodeAddress
end.kind"block"yesConstant: "block"
end.nodeIdstringyes
end.nodeTypeenumyes"paragraph", "heading", "listItem", "table", "tableRow", "tableCell", "tableOfContents", "image", "sdt"
startBlockNodeAddressyesBlockNodeAddress
start.kind"block"yesConstant: "block"
start.nodeIdstringyes
start.nodeTypeenumyes"paragraph", "heading", "listItem", "table", "tableRow", "tableCell", "tableOfContents", "image", "sdt"

Example request

{
  "end": {
    "kind": "block",
    "nodeId": "node-def456",
    "nodeType": "paragraph"
  },
  "start": {
    "kind": "block",
    "nodeId": "node-def456",
    "nodeType": "paragraph"
  }
}

Output fields

FieldTypeRequiredDescription
deletedBlocksobject[]yes
deletedCountnumberyes
dryRunbooleanyes
revisionobjectyes
revision.afterstringyes
revision.beforestringyes
successtrueyesConstant: true

Example response

{
  "deletedBlocks": [
    {
      "nodeId": "node-def456",
      "nodeType": "paragraph",
      "ordinal": 1,
      "textPreview": "example"
    }
  ],
  "deletedCount": 12.5,
  "dryRun": true,
  "revision": {
    "after": "example",
    "before": "example"
  },
  "success": true
}

Pre-apply throws

  • TARGET_NOT_FOUND
  • AMBIGUOUS_TARGET
  • INVALID_TARGET
  • INVALID_INPUT
  • CAPABILITY_UNAVAILABLE
  • INTERNAL_ERROR

Non-applied failure codes

  • None

Raw schemas

{
  "additionalProperties": false,
  "properties": {
    "end": {
      "$ref": "#/$defs/BlockNodeAddress"
    },
    "start": {
      "$ref": "#/$defs/BlockNodeAddress"
    }
  },
  "required": [
    "start",
    "end"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "deletedBlocks": {
      "items": {
        "additionalProperties": false,
        "properties": {
          "nodeId": {
            "type": "string"
          },
          "nodeType": {
            "type": "string"
          },
          "ordinal": {
            "type": "number"
          },
          "textPreview": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "ordinal",
          "nodeId",
          "nodeType",
          "textPreview"
        ],
        "type": "object"
      },
      "type": "array"
    },
    "deletedCount": {
      "type": "number"
    },
    "dryRun": {
      "type": "boolean"
    },
    "revision": {
      "additionalProperties": false,
      "properties": {
        "after": {
          "type": "string"
        },
        "before": {
          "type": "string"
        }
      },
      "required": [
        "before",
        "after"
      ],
      "type": "object"
    },
    "success": {
      "const": true
    }
  },
  "required": [
    "success",
    "deletedCount",
    "deletedBlocks",
    "revision",
    "dryRun"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "deletedBlocks": {
      "type": "array"
    },
    "deletedCount": {
      "type": "number"
    },
    "dryRun": {
      "type": "boolean"
    },
    "revision": {
      "additionalProperties": false,
      "properties": {
        "after": {
          "type": "string"
        },
        "before": {
          "type": "string"
        }
      },
      "required": [
        "before",
        "after"
      ],
      "type": "object"
    },
    "success": {
      "const": true
    }
  },
  "required": [
    "success",
    "deletedCount",
    "deletedBlocks",
    "revision",
    "dryRun"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "failure": {
      "additionalProperties": false,
      "properties": {
        "code": {
          "enum": [
            "TARGET_NOT_FOUND",
            "AMBIGUOUS_TARGET",
            "INVALID_TARGET",
            "INVALID_INPUT",
            "CAPABILITY_UNAVAILABLE",
            "INTERNAL_ERROR"
          ]
        },
        "details": {},
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "type": "object"
    },
    "success": {
      "const": false
    }
  },
  "required": [
    "success",
    "failure"
  ],
  "type": "object"
}