Apply design operations
apply_operationsApply a batch of validated design operations atomically: all edits save only if every schema, reference, and content check passes; any error leaves the project unchanged.
Instructions
Apply a batch of structured operations atomically: everything is validated (schema, references, content protection) before anything is saved; on any error nothing changes. No scripts or code are executed.
apply_operations reference
All coordinates are canvas pixels. Omitted ids are generated. Patches deep-merge (objects merge, arrays replace, null deletes).
Pages: add_page {page:{id?,name?,width,height,background?},index?} · duplicate_page {pageId,newPageId?,name?} · update_page {pageId,name?,width?,height?,background?} · remove_page {pageId} · move_page {pageId,index} · set_background {pageId,background} Layers: add_layer {pageId,layer,parentId?,index?} · update_layer {pageId,layerId,patch} · remove_layer {pageId,layerId} · reorder_layer {pageId,layerId,position:"front"|"back"|"forward"|"backward"|index} · group_layers {pageId,layerIds,groupId?,name?} · ungroup {pageId,groupId} Assets/brand: replace_asset {fromAssetId,toAssetId,pageIds?} · set_asset_protection {assetId,enabled?,grant?:{effect,authorization},revoke?,authorization?} · set_brand {brand|null} · rename_project {name}
Background: {type:"solid",color} | {type:"gradient",gradient:{type:"linear",angle,stops:[{color,at}]}|{type:"radial",cx,cy,stops}} | {type:"image",assetId,fit:"cover"|"contain",position:{x,y},overlay?,overlayOpacity?} | {type:"none"} (transparent). Any of them may add pattern:{kind:"dots"|"grid"|"diagonal"|"waves",color,size}.
Common layer fields: id?, name?, x, y, width, rotation=0, opacity=1, visible=true, shadow?:{x,y,blur,spread,color}.
device: {type:"device",frame:"none"|"thin"|"phone"|"tablet"|"laptop"|"browser"|"window",assetId?,frameOptions?:{color,bezel?,cornerRadius?,screenRadius?,screenCorners:"auto"|"inset"|"clip",buttons,depth(0..1, 3D edge),chromeColor?,addressText?,screenColor?},perspective?} — default "inset" corners: rounded display, screenshot fully inside (no pixel cut), band filled with the screenshot's own edge colors; "clip" rounds the screenshot itself and needs the cornerRadius grant for more than 3% — height is derived from width and the screenshot aspect; patch only "height" to resize by height.
image: {type:"image",assetId,height?,fit:"contain"|"cover"|"fill",crop?,cornerRadius,border?,perspective?} — height defaults to the asset aspect.
text: {type:"text",text,height?,style:{fontFamily,fontSize,fontWeight,italic,color,align,verticalAlign,lineHeight,letterSpacing,textTransform,underline,stroke?,textShadow?},highlights?:[{text,color?,backgroundColor?,bold?,italic?,underline?,fontFamily?,paddingX?,paddingY?,cornerRadius?,opacity?}],box?:{fill?,padding,cornerRadius,border?}}
shape: {type:"shape",shape:"rect"|"ellipse"|"pill"|"triangle"|"diamond"|"star"|"burst"|"spark"|"blob"|"arch"|"ring"|"line"|"arrow"|"wave",height,fill (color or gradient),stroke?:{width,color},cornerRadius}
group: {type:"group",x,y,width,height,children:[…]} — child coordinates are relative to the group. Colors: #rgb, #rrggbb, #rrggbbaa, rgb(), rgba(), transparent.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"project": "<project>",
"operations": "<operations>"
},
"name": "apply_operations"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | Yes | Project id returned by create_project/open_project in this session, or the project directory path. | |
| operations | Yes | Ordered operations; see the tool description for every op and layer field. | |
| expectedRevision | No | Fail if the project revision differs (optimistic locking). |