Board editing is a JSON document protocol shared by the API, SDK, CLI, web editor, checkpoints, and published Apps. The document describes what a Board means; renderers derive geometry and presentation from it.
Document
{
"board": { "background": { "kind": "dots" }, "grid": { "visible": true, "size": 24 }, "enter": { "preset": "deal" } },
"items": { "id": { "type": "text", "position": { "x": 0, "y": 0 }, "props": { "text": "Hi" } } },
"animations": { "intro": { "duration": 800, "tracks": { "t": { "target": "id", "property": "opacity", "keyframes": [{ "at": 0, "value": 0 }, { "at": 800, "value": 1 }] } } } }
}Authoring is a merge patch by default: boards apply (or the SDK equivalent) merges the input into the document. --replace makes the document equal to the input. Deleting a referenced item fails and lists references; --cascade also deletes children and targeting tracks.
Geometry
positionis relative toparent; a root item is in world space.drawpoints and unboundarrowendpoints are item-local; bound endpoints follow the referenced item.sizeis authored for boxes (frame,shape, media,task,effect,custom) and derived fortext,draw, andarrow.styleaccepts palette tokens, CSS colors, light/dark pairs, plusdash,radius, andtrim.
Use cohub boards schema <target> --field <path> to read the exact value type, units, and composition (for example camera fields) instead of guessing.
Scripts
custom items and native items can carry a script attachment (src, params, targets, seed, enabled). Scripts run in one isolated module runtime shared by browser, CLI, and exports, declare their own hitRegions(), and commit document changes explicitly. ESM entry modules publish with their transitive dependencies.
Validation and concurrency
- Every write reports a Board version. Pass
--base-versionto fail when the Board has moved past it. - Pass
--mutation-idso a retry never applies twice. --dry-runvalidates without writing.- Validation failures name the authoring path (for example
items.0.props.text).
CLI workflow
# Inspect
cohub boards get <board> --only board,items --json
cohub boards get <board> --within <frame-id> --json
cohub boards schema <target> --field props.geometry
# Write
cohub boards apply <board> -i patch.json --dry-run
cohub boards apply <board> -i patch.json --base-version 12 --mutation-id <stable-id>
cohub boards apply <board> -i doc.json --replace
# History and restore
cohub boards history <board> --limit 20 --json
cohub boards history <board> --restore 12Animation presets
cohub boards preset <name> --at 0 --stagger 80 --duration 600 --ease ease-out --json
cohub boards preset <name> --animation intro --jsonWithout --animation, presets emit bare tracks; with it, they wrap the tracks in that animation.
Retry rules
- Reuse the same
mutation-idafter a timeout. - Use
--base-versionto reject a stale snapshot. - After a version conflict, read the latest Board and rebase the patch.
- Fix a reported validation path; do not retry unchanged JSON.
Avoid
- Writing legacy Node/Sequence shapes or the pre-v3
frameenvelope. - Treating a screenshot or renderer cache as the source of truth.
- Sending unbounded JSON or unsupported item properties.
- Replacing a timed-out write with a new mutation id.