Skip to content
中文

Canvas

Praxis Canvas lets agents create and edit designs with scripts while people watch the same infinite canvas live in Console. Draw pages, slides, diagrams and interface components, then export selected nodes as PNG.

When to use it

Designs drawn by script on a live canvas, exported as files.

Use it when

  • Screens, diagrams, posters, and slides: one 1920×1080 frame each, export pptx.

Not for, use instead

  • A working site → application
  • Video → cut

How it behaves

  • Each execute is versioned; one section per call; never edit one canvas in parallel.

Combines with

  • Share the viewer_url.

Entry: praxis.canvas.* · docs developers/canvas/index

Choose an entry point

TaskEntry pointResult
Create and export your first designQuickstartCreate a canvas, draw a frame, save a PNG
Look up node fields and layoutNode referenceObjects you can pass directly to Insert
Write or repair a scriptScript functionsSignatures, return values, visitors and persistent globals
Recover from a failureLimits and errorsLimits, rollback, concurrency and retries

Canvases and nodes

A canvas is a design document owned by an organization. Creation returns an id, a string version and a viewer_url. Share viewer_url with a viewer to watch the Console /canvases/{id} page live; API calls require access to the owning organization.

A canvas contains ordered top-level nodes; frames and groups can contain children. Nodes use the pen.dev .pen 2.21 data shape; the node reference defines the fields actually supported. They are not Figma nodes, HTML or CSS. Unknown fields can survive storage, but successful storage does not mean layout or painting supports them.

Reusable components are nodes marked reusable: true. A ref instance shares component content and can override descendant properties. Variables and themes belong to the canvas; nodes reference variables with "$name".

Call and view

Use praxis.canvas.canvases in codemode; the public HTTP surface is /canvas/v1. create creates a canvas, retrieve reads its version and top-level nodes, execute runs synchronous JavaScript to edit it, nodes.list reads node trees, and images.list returns PNG data URLs.

A successful execute containing writes increments the version once and returns created nodes, prints, warnings and affected top-level nodes. Read-only scripts do not increment it. Failure rolls back this call’s writes. To guard concurrent editing, pass the expected_version you just read.

TakeScreenshot only records node IDs to capture. Fetch actual images with images.list. Images are inline data URLs, not hosted download links; your own code decodes and saves them. An agent in codemode just returns them and sees the images directly (at most 4 per run), without saving files. A render loads at most 16 font faces and 16 MiB of font data; a face past that paints in a fallback family, and the response then carries warnings with a FONT_SKIPPED entry naming the face and the family that painted instead.

Version history and restore

Every successful write (execute, import or restore) is kept as a version. When a script succeeds but changes the wrong things, find the version before it with praxis.canvas.canvases.versions.list({ path: { canvas_id } }), then call praxis.canvas.canvases.restore({ path: { canvas_id }, body: { version, expected_version } }). A restore creates a new version itself, so it can be restored away again.

const { versions } = await praxis.canvas.canvases.versions.list({ path: { canvas_id } });
const bad = versions[0]; // the latest commit
await praxis.canvas.canvases.restore({ path: { canvas_id },
body: { version: String(Number(bad.version) - 1), expected_version: bad.version } });

To look at an old version without changing the canvas, pass version to nodes.list or images.list. All versions from the last 30 days are kept, and the newest 100 always are; when history exceeds 256 MiB the oldest go first. earliest_restorable_version is the oldest version you can still read or restore.

Organize with collections

Collections provide one level of organization; each canvas belongs to zero or one collection. In the Console canvas list, create a collection in the left rail, select canvases and choose “移到画册” to move them together. “未归类” shows canvases without a collection.

In codemode, create a collection with praxis.canvas.collections.create({ body: { name: "Console" } }), then move a canvas with praxis.canvas.canvases.update({ path: { canvas_id: canvasId }, body: { collection_id: collectionId } }). Get canvasId from canvas creation or listing and collectionId from collection creation or listing. Call praxis.canvas.collections.list() for all collections and counts. Use praxis.canvas.canvases.list({ query: { collection_id: collectionId } }) to read the canvases inside one; preserve the filter when following the next cursor.

Names contain 1–100 characters after trimming; duplicates are allowed. Each organization can have at most 200 collections; exceeding this returns 422 COLLECTION_LIMIT. Rename with collections.update and read one with collections.retrieve. Calling collections.delete preserves all its canvases and makes them uncategorized. Updating a canvas with collection_id: null also removes its collection; to list uncategorized canvases, pass the string "none" as the query filter. canvases.update can also change only name; omitting collection_id preserves the assignment.

Next steps

Complete your first design with the quickstart. See the Canvas API reference for complete request and response fields.