cnap.request() API, the same V8 isolate, the same security model. You can write snippets by hand, or let an AI agent build your dashboards for you.
How It Works
Dashboards are built from two building blocks:- Snippets — JavaScript functions that query the CNAP API and return data. Each snippet has a display type (table, stat, JSON, or logs) that controls how the result is rendered.
- Dashboards — Grid layouts that arrange snippets as widgets. Each widget can span 1–4 columns and runs its snippet automatically when you open the dashboard.
Creating a Snippet
Navigate to Dashboards → Snippets tab and click New Snippet. Snippets areasync JavaScript functions that use cnap.request() to call the CNAP API. The workspace header is injected automatically — you don’t need to pass authentication or workspace IDs.
Display Types
The display type controls how the snippet result is rendered in dashboard widgets:| Display Type | Return Value | Use Case |
|---|---|---|
| Table | Array of objects | List resources with columns |
| Stat | Single number or string | KPIs, counts, status values |
| JSON | Any object | Structured data, breakdowns |
| Logs | String | Text reports, log output |
The cnap.request() API
This is the same API available in MCP Code Mode. Snippets run in a sandboxed environment with access to a single function:
Snippets execute server-side in an isolated V8 sandbox — the same sandbox that powers Code Mode. They cannot access
require, process, fs, or any Node.js APIs — only cnap.request() is available.Creating a Dashboard
Navigate to Dashboards tab and click New Dashboard. Give it a name and optional description, then click Create Dashboard to open the builder.The Dashboard Builder
Dashboards open in view mode by default, showing your widgets in a live grid. Click Edit to enter edit mode, where overlay controls appear on each widget:- Move up/down — Reorder widgets in the grid
- Resize (−/+) — Adjust column span from 1/4 to full width
- Edit snippet — Jump to the snippet editor
- Delete — Remove the widget
Workspace Scoping
Snippets and dashboards follow the same workspace scoping as other CNAP resources:- When a workspace is selected — You see snippets and dashboards belonging to that workspace
- When “All Workspaces” is selected — You see snippets and dashboards from all workspaces you have access to
Related Topics
- Generate Dashboards with AI → — Let an AI agent build and iterate on dashboards for you
- Code Mode in Action → — See how the same sandbox powers AI agent operations
- API Reference → — Explore available API endpoints for snippets
- Workspaces → — Understand how workspaces organize resources