> ## Documentation Index
> Fetch the complete documentation index at: https://opencanvas.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# get_selection: Read Selected Components

> Retrieve the component IDs of whatever the user has currently selected in the DesignJS editor, enabling context-aware agent actions.

The `get_selection` tool reads the current editor selection and returns the IDs of all selected components. This creates a direct collaboration channel between you and your agent: you select the element you want the agent to work on, then your agent calls `get_selection` to discover your intent without needing you to type out a component ID manually.

This is particularly useful in interactive workflows where you want the agent to apply changes to whichever element you're focused on in the editor — whether that's a single button, a navigation bar, or a multi-selected group of cards.

## Parameters

`get_selection` takes no parameters. Pass an empty object as arguments.

## Response

<ResponseField name="componentIds" type="string[]" required>
  An array of component ID strings for all currently selected components. Returns an empty array (`[]`) if nothing is selected in the editor.
</ResponseField>

## Example

<CodeGroup>
  ```json request theme={null}
  {
    "method": "tools/call",
    "params": {
      "name": "get_selection",
      "arguments": {}
    }
  }
  ```

  ```json response — with selection theme={null}
  {
    "content": [
      {
        "type": "text",
        "text": "{\"componentIds\": [\"comp-hero-btn\"]}"
      }
    ]
  }
  ```

  ```json response — nothing selected theme={null}
  {
    "content": [
      {
        "type": "text",
        "text": "{\"componentIds\": []}"
      }
    ]
  }
  ```
</CodeGroup>

<Tip>
  Build agent prompts around selection. For example: "Select a component in the canvas, then ask your agent to change its background color." The agent calls `get_selection` to get the ID, then calls `update_styles` with that ID — no manual ID lookup required.
</Tip>

<Note>
  If multiple components are selected in the editor, all of their IDs are returned in the array. You can pass this entire array to `delete_nodes` to remove them all at once.
</Note>
