Skip to main content
The delete_nodes tool removes components from the canvas by their IDs. Each deleted component takes its entire child subtree with it — all nested elements are removed in a single call. The response tells you how many total nodes (including children) were deleted, which is useful for confirming the operation completed as expected. You can delete multiple components in one call by passing several IDs in the array. This is more efficient than calling delete_nodes repeatedly and reduces the number of round-trips between your agent and the canvas.

Parameters

string[]
required
An array of component IDs to remove from the canvas. Each ID should correspond to a component currently on the canvas. Obtain IDs from get_tree, get_selection, add_components, or list_artboards. Non-existent IDs are silently ignored.

Response

number
required
The total count of nodes removed from the canvas, including all descendants of the targeted components. For example, deleting a <section> that contains three child <div> elements returns deleted: 4.

Example

response
Deletion is immediate and removes child nodes permanently from the canvas state. The operation can be undone using Cmd+Z (or Ctrl+Z) in the editor, but there is no undo API — your agent cannot programmatically reverse a deletion.
To delete whatever the user currently has selected in the editor, call get_selection first to retrieve the IDs, then pass the returned array directly to delete_nodes. This lets users point to what they want removed without typing IDs.