Apply edits (batch)
apply_editsApply multiple SVG edits as one atomic, reversible operation. Batch create, style, arrange, delete, or transform objects in a single call with all-or-nothing rollback.
Instructions
Apply an ordered list of typed DOM edits to a document as ONE atomic, reversible operation.
When to use: making SEVERAL edits to one document in a single call (draw + style + arrange,
re-theme + rename, …) instead of N separate tool round-trips. Each member is the SAME typed
edit the dedicated tool exposes — apply_edits adds atomicity + one snapshot, not new
authority. For a single edit, call the dedicated tool (set_fill, move_object, …); for path
geometry or cross-document composition use those tools directly (they are NOT batchable).
Key params: edits is a non-empty, ordered list (max 64) of typed edits, each tagged by an op
field that selects its schema — e.g. {"op": "create_rect", "x": 0, "y": 0, "width": 100, "height": 60, "fill": "#3366cc"}, {"op": "set_fill", "object_ids": ["logo"], "color": "red"},
{"op": "move_object", "object_id": "logo", "dx": 10, "dy": 0}. Supported ops mirror the typed
DOM tools: set_fill / set_stroke / set_opacity / replace_color / apply_palette /
replace_text / set_font / duplicate_object / rename_object / delete_object (high) /
move_object / scale_object / rotate_object / resize_canvas / normalize_viewbox /
tile / create_rect / create_circle / create_ellipse / create_line / create_polygon /
create_polyline / create_path / create_text / create_group / group_objects /
reparent_object / create_use / add_linear_gradient / add_radial_gradient. Validation is
two-phase: ALL members are validated before any mutation (one bad edit leaves the document
byte-identical), then applied in order with all-or-nothing rollback on any failure. If ANY
member is high-risk (a delete_object edit) the WHOLE batch is HIGH and requires a non-empty
approval_token; otherwise it is medium.
Render and look before you trust the edit: a batch changes several things at once, so call
render_preview (or live_render_view in live mode) afterwards and inspect the result before
relying on it — and restore_snapshot(doc_id, snapshot_id) reverts the whole batch in one step.
Return shape: BatchEditResult — the pipeline fields for the single batch operation
(operation_id, snapshot_id, changed, before/after preview; reversible) PLUS edit_count
and the effective risk_class.
Example: apply_edits(doc_id, [{"op": "create_rect", "x": 0, "y": 0, "width": 100, "height": 60, "fill": "#eee", "object_id": "bg"}, {"op": "create_text", "x": 10, "y": 30, "text": "Hi"}])
Risk class: medium (effective risk is the MAX over members; a delete_object member escalates
the batch to high and requires approval_token). Reversible via the single pre-batch snapshot.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| edits | Yes | ||
| doc_id | Yes | ||
| approval_token | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | ||
| changed | Yes | ||
| summary | No | ||
| edit_count | Yes | ||
| risk_class | Yes | ||
| snapshot_id | Yes | ||
| operation_id | Yes | ||
| preview_after | No | ||
| preview_before | No |