When you need to create shapes programmatically, you can use the Factory object.
// create a rectangleconst rectangle = editor.factory.createRectangle([[0, 0], [100, 100]]);rectangle.fillColor = "#ff0000";rectangle.strokeColor = "#00ff00";rectangle.strokeWidth = 3;rectangle.roughness = 2; // insert into current pageeditor.actions.insert(rectangle);