Add an element
add_elementAdd a new element to an existing scene. Use this to insert nodes, groups, connections, or shapes into a diagram you already drew, then call render_scene to display the updated diagram.
Instructions
Add one element to a scene that already exists.
USE THIS when the user wants something new in a diagram you already drew: "add a load balancer", "put a Redis cache next to the API", "draw an arrow from A to B".
Call get_scene first if you are not certain which ids exist. To link the new element to an existing one, make a second call with an element of type 'connection' referencing the two ids - the geometry is computed for you.
Omit x/y and the layout engine places it. Set parentId to put it inside a group.
This does not display anything. Call render_scene once your edits are done.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| element | Yes | The element to add: an object with a unique `id`, a `type`, and the properties of that type - exactly the same shape as the entries of `elements` in render_diagram. Types: node, connection, group, axis, point, scatter, cluster, plotLine, label, server, database, router, switch, computer, cloud, circle, ellipse, rectangle, line, arrow, text, polygon, polyline, path. Example: { "id": "cache", "type": "database", "label": "Redis" }. | |
| sceneId | Yes | Id of the scene to work on, as returned by render_diagram or create_scene. | |
| parentId | No | Id of a 'group' element to nest this inside. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error | No | Present only when success is false. | |
| sceneId | No | ||
| success | Yes | ||
| elementId | No | ||
| elementCount | No | Top-level elements in the scene after the add. |