Reading versions needs a publishable (
pk_) or secret (sk_) key with
worlds:read. Snapshotting and checking out need a secret key with
worlds:write.How the tree works
- A version is a full snapshot of a world’s graph at a point in time, plus
metadata:
id,parentVersionId,source,title, andcreatedAt. - HEAD is the version your working graph currently descends from.
- Snapshotting onto the current HEAD advances HEAD — a linear “save”. Snapshotting off an older parent forks a branch and leaves HEAD alone.
sourcerecords how a version was made:save,branch,manual,ai(an agent edit), orimport.
Snapshot a version
Capture the world’s current graph as a new version. OmitparentVersionId to
snapshot onto the current HEAD.
List the tree
GET /v1/worlds/{id}/versions returns every node oldest-first; rebuild the tree
from each node’s parentVersionId.
GET /v1/worlds/{id}/versions/{versionId}; it returns the version metadata plus
the complete snapshot world.
Check out a version
Checking out sets the working graph to a version’s snapshot and moves HEAD onto it, atomically. A later snapshot then branches off the checked-out version. The response carries the restoredworld and the new rev (also the ETag).
Like every world write, checkout honors If-Match / expectedRev and returns
409 if a concurrent edit advanced the rev, so a checkout never silently
clobbers an in-flight edit.
Diff two versions
GET /v1/worlds/{id}/versions/{a}/diff/{b} returns a pure structural diff
between version a (base) and version b (target). States are keyed by their
record key, events by their unique name; changed means present in both but not
byte-identical.
Status codes
| Status | Meaning |
|---|---|
200 | OK. Snapshot/checkout/diff/list/get succeeded. |
400 | A required field is missing (e.g. versionId on checkout). |
404 | The world or a referenced version doesn’t exist, or isn’t yours. |
409 | The rev you asserted is stale — a concurrent edit moved it; reload and retry. |