Install: npm install @canvasmesh/sdk-js. Works in Node.js, browsers, and edge runtimes (Cloudflare Workers, Deno). Ships ESM and CJS.
import { CanvasClient } from '@canvasmesh/sdk-js';
const client = new CanvasClient({ apiKey, endpoint? });
| Option | Type | Required | Default |
|---|
apiKey | string | yes | — |
endpoint | string | no | https://api.canvasmesh.app |
client.create(options: CreateCanvasOptions): Promise<CanvasMesh & { view_url: string }>
| Option | Type | Required |
|---|
title | string | yes |
ext | string (e.g. 'md') | yes |
content | string | Blob | ArrayBuffer | yes |
render | RenderType | no |
visibility | 'private' | 'public' | no |
client.update(canvasId: string, options: UpdateCanvasOptions): Promise<CanvasMesh>
All options optional. Only pass what you want to change.
| Option | Type |
|---|
title | string |
content | string | Blob | ArrayBuffer |
visibility | CanvasVisibility |
render | RenderType |
client.get(canvasId: string): Promise<CanvasMesh>
client.list(options?: ListCanvasOptions): Promise<{ canvases: CanvasMesh[] }>
| Option | Type | Default |
|---|
visibility | CanvasVisibility | — |
limit | number | 20 (max 100) |
offset | number | 0 |
client.delete(canvasId: string): Promise<void>
client.share(canvasId: string, options?: ShareOptions): Promise<CanvasShare & { url: string }>
| Option | Type | Example |
|---|
expiresIn | string | '7d', '24h', '30m' |
client.getContent(canvasId: string): Promise<string>
Fetches the raw file content as a string. For binary files use fetch(canvas.content_url) with appropriate parsing.
| 'none' | 'html' | 'markdown' | 'react'
| 'svg' | 'json' | 'text' | 'image' | 'notebook';
type CanvasVisibility = 'private' | 'public';
visibility: CanvasVisibility;
expires_at: string | null;
expires_at: string | null;
interface ListCanvasOptions {
visibility?: CanvasVisibility;
All methods throw on non-2xx responses. The thrown Error has a status property (HTTP status code) and body property (parsed JSON or text).
await client.get('cv_invalid');
if (err.status === 404) {