Notebooks
Ordered cells of markdown, SQL, metric queries, and Python that persist as git-tracked YAML. History, at-SHA replay, and per-cell content caps.
A notebook is a git-tracked, ordered list of cells mixing markdown, SQL, metric queries, and in-browser Python. It is the narrative-first surface next to the SQL IDE and the dashboard grid: use it when the answer needs prose around it, an ad-hoc calc, or a chart that is not worth pinning to a dashboard.
You’ll learn
- What a notebook is on disk and which endpoints back it
- The four cell types (markdown, sql, metric, python) and how each executes
- How autosave and versioned history round-trip through git
- How to fork a notebook
- Per-write size caps that keep the git store bounded
What are notebooks
A notebook is one YAML file at notebooks/<id>.yaml inside the tenant’s git-backed artifact store. It carries a name, an optional description, an ordered cells list, a workspace_id for RBAC scoping, and a free-form tags list. Every write is a real git commit, so history and diff plumbing are identical to charts, dashboards, and saved queries. The author on the commit is always the authenticated session; the browser cannot stamp another user’s identity onto the commit.
Endpoints:
| Method | Path | Permission | Notes |
|---|---|---|---|
| GET | /api/notebooks | authenticated + allow_notebooks filter | Workspace + per-id allow-list applied server-side. |
| GET | /api/notebooks/{id} | allow_notebooks match | 404 (not 403) when denied, to prevent id enumeration. |
| PUT | /api/notebooks/{id} | allow_save | Body cap 16 MiB; If-Match / ETag optimistic concurrency; author is server-derived. |
| DELETE | /api/notebooks/{id} | allow_delete | Workspace-gated on the existing artifact before deletion. |
| POST | /api/notebooks/{id}/fork | allow_save + source-workspace ACL | Deep-copy into a new notebook you own. |
| GET | /api/notebooks/{id}/history | authenticated + workspace | Returns the git log for the file. |
| GET | /api/notebooks/{id}/at/{sha} | authenticated + workspace | Fetches the YAML as it existed at that SHA. |
Anonymous callers on the list endpoint get 401 - the list handler will not return notebooks with a blank workspace to an unauthenticated caller.
Cell types
Every cell has an id, a type, and a type-specific payload. Missing ids are auto-assigned c-1, c-2, … on save; missing type defaults to markdown so a client that emits a raw text block is never rejected on shape.
| Type | Payload fields | How it runs |
|---|---|---|
markdown | content | Rendered client-side; never touches the warehouse. |
sql | content (raw SQL), optional chart_kind | Executed through POST /api/query under the caller’s identity. The same allow_save gate applies as in the SQL IDE. |
metric | metric, dimensions[], time_grain, filters{}, optional chart_kind, optional title | Compiled through the semantic layer and executed via POST /api/metric/{name}/query. Row-level filters and column masks from the caller’s role apply. |
python | content (Python source) | Executed in-browser via Pyodide. The worker’s stdout, stderr, matplotlib figures, and result are persisted back to the cell as python_output so a viewer opening the notebook fresh sees the last run. |
Python cell output is opaque to the server: python_output round-trips through the store as JSON so future field additions (DataFrame HTML, package-load status) do not need a store migration.
Autosave
The notebook editor SPA debounces changes locally and issues a PUT /api/notebooks/{id} on quiet intervals; every write commits to git. Because writes are commits, autosave produces a granular history a coworker can walk with history + at/{sha} below. Concurrent-edit safety is the If-Match ETag: a PUT with a stale ETag returns 412 Precondition Failed instead of overwriting a coworker’s change, so an autosave that races another tab is caught server-side.
The exact interval and pause heuristic live in the SPA and are refined as UX feedback lands; treat “on every quiet interval” as the contract, not a promise about a specific millisecond debounce.
History and at-SHA replay
Every commit through PUT /api/notebooks/{id} shows up on GET /api/notebooks/{id}/history with author, timestamp, message, and SHA:
curl -H "Authorization: Bearer $GONI_PAT" \
https://your-goni-host/api/notebooks/weekly-arr/history?limit=20
Pass a specific SHA back to at/{sha} to fetch the notebook exactly as it existed then, without altering the current head:
curl -H "Authorization: Bearer $GONI_PAT" \
https://your-goni-host/api/notebooks/weekly-arr/at/9c1f2a3
Both endpoints require an authenticated session and pass the same workspace + per-id ACL checks as the read endpoints, so a viewer that cannot see the notebook cannot walk its history either. The limit query parameter on /history is clamped server-side; unbounded reads are not offered.
Fork
POST /api/notebooks/{id}/fork deep-copies a notebook you can read into a new one you own. The fork regenerates every cells[].id, defaults the new id to <source>-copy (or a suffix collision-avoids), and stamps the authenticated caller as the author. allow_save on the caller plus the source-workspace ACL are required. The destination workspace defaults to the source; pass a workspace_id in the JSON body to fork into a different workspace you belong to.
Per-write size caps
The write path caps the request body at 16 MiB. That accommodates a legitimate notebook carrying several matplotlib figures without letting the git-backed store balloon: an unbounded body previously let a client commit a half-gig base64 figure to disk. Per-cell caps are not enforced today - the 16 MiB per-PUT ceiling is the load-bearing bound.
If your Python cell produces a very large figure or a very long stdout, the recommended pattern is to write the artifact through the connector or export path and reference it from the notebook, not to inline the payload.
RBAC and workspace scoping
Notebooks share the artifact ACL surface with charts, dashboards, and saved queries: a workspace_id scopes the notebook to a workspace; the sidebar’s workspace switcher passes ?workspace=<id> to GET /api/notebooks and the server filters server-side. Per-id allow_notebooks glob-matches on top so a role can be scoped to ["team-onboarding-*"] without granting the whole surface. Empty allow_notebooks on a role denies. See Access control for the underlying default-deny model and Tags reference for the shared tag taxonomy.
Related
- SQL IDE - the raw-SQL surface every
sqlcell shares under the hood - Charts - the artifact a chart-worthy cell should graduate into
- Dashboards - where a stable metric view belongs when the narrative is done
- Access control - workspace + per-id gates for notebooks
- Audit and lineage - every notebook
PUTandDELETEis recorded - Tags reference - free-form tag taxonomy shared with charts, dashboards, and saved queries
Last updated