Create new diagram
create_new_diagramCreate a new diagram from scratch, replacing the whole draw.io document and its unsaved changes. Use it to provide the mxCell XML for a fresh diagram instead of editing an existing one.
Instructions
Create a NEW diagram, REPLACING the whole document: every page and any unsaved user changes (the previous state stays in History). To add a tab use add_page; to change cells use edit_diagram.
Before using icon shapes (AWS, Azure, GCP, Kubernetes, Cisco...), call get_shape_library first. Follow the drawing guide returned by start_session (call get_drawing_guide if it is no longer in your context). Pass screenshot: true on the last call of a complex diagram to check the result.
Accepted xml:
Only the mxCell elements of one page (recommended). The server adds , , and the root cells "0" and "1":
A bare with (one page).
A full with one or more pages. Every page's must start with .
Rules: cells are siblings (never nested), ids are unique per page and start from "2", parent only for shapes inside a container, no XML comments, and shapes stay within x 0 to 800 and y 0 to 600. A style used by several cells is defined once with before the cells and used by name (see the drawing guide); html=1 and whiteSpace=wrap are added automatically.
To clear the canvas to one blank page, send only the two root cells ; the previous diagram stays in History.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| xml | Yes | REQUIRED: the mxCell elements of one page, a bare <mxGraphModel>, or a full <mxfile> with one or more <diagram> pages. | |
| screenshot | No | Also return a PNG of the result so you can check it for overlaps and edges crossing shapes. Needs the preview tab open and in front; adds 2 to 10 s. Default: the DRAWIO_AUTO_SCREENSHOT environment variable. |