Skip to main content
Every world keeps a version tree: a branching history of full graph snapshots, plus a HEAD pointer that tracks the working graph. Snapshot a version before a risky change, branch to explore an alternative, check out an older snapshot to roll back, and diff any two versions to see exactly what moved.
Reading versions needs a publishable (pk_) or secret (sk_) key with worlds:read. Snapshotting, checking out, renaming, and pruning need a secret key with worlds:write. Never ship a secret key to a browser.

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, and createdAt.
  • 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.
  • source records how a version was made: save, branch, manual, ai (an agent edit), or import.
  • Pruning a version deletes only that node and re-roots its children onto its parent, so the tree never fragments. You can’t prune the version HEAD currently points at. Check out another version first.

Snapshot a version

Capture the world’s current graph as a new version. Omit parentVersionId 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.
Fetch one snapshot in full, graph and all, with 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 restored world 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.
The diff is shaped like this:

Rename a version

PATCH /v1/worlds/{id}/versions/{versionId} changes a version’s title and nothing else: it never touches the snapshot, the parent pointer, or HEAD. title is required. Send an empty or missing one and the call comes back 400. The response echoes the versionId and the trimmed title.

Prune a version

DELETE /v1/worlds/{id}/versions/{versionId} removes a single version node. Any children it had are re-rooted onto the pruned node’s parent, so the tree stays connected. You never orphan a branch by deleting a node in the middle of it. The response returns { ok: true, deleted } with the id you removed.
You cannot prune the version HEAD currently points at, because that would leave head_version_id dangling. The API refuses with 409. Check out another version first (see Check out a version), then prune the one you no longer need.

Status codes