Graph data
3. Graphs and snapshots
All routes in this section take a session token. GET /v1/graphs/{graphId}/export also accepts a live key whose scope holds export (see Export).
| Method | Path | Purpose |
|---|---|---|
| GET | /v1/graphs |
List readable graphs |
| PUT | /v1/graphs/{graphId} |
Publish (create or replace) a personal graph from a snapshot |
| PATCH | /v1/graphs/{graphId} |
Turn server-side AI on or off; unlock web editing |
| DELETE | /v1/graphs/{graphId} |
Remove a graph from the server |
| GET | /v1/graphs/{graphId}/export |
Download a graph as a snapshot |
PUT / GET |
/v1/graphs/{graphId}/sealed |
Store / fetch an encrypted graph |
| POST | /v1/orgs/{orgId}/graphs |
Create an empty organisation graph, or move a personal graph into an organisation |
A new, empty personal graph can also be created with a live key through the create_graph operation (section 5.6).
3.1 List graphs#
GET/v1/graphs
| Query parameter | Description |
|---|---|
orgs=1 |
Also list the graphs of every organisation the caller is a member of. Without it, only the caller's personal graphs are returned. |
Response 200:
{
"graphs": [
{
"graphId": "team-kb",
"label": "Team knowledge base",
"revision": 42,
"nodes": 1280,
"edges": 3410,
"updatedAt": 1790000000,
"serverAi": false
},
{
"graphId": "5f0c…",
"label": "Company brain",
"revision": 911,
"updatedAt": 1790000500,
"serverAi": true,
"orgId": "…",
"orgName": "Example Ltd",
"role": "admin"
}
]
}
Organisation graphs carry orgId, orgName and role, and deliberately omit nodes and edges: the size of the whole graph is not something every member may read. The list is not paginated. Personal graphs come first, each set ordered by most recently updated.
Errors: 401 unauthorized.
curl -s "https://graphlife.example.com/v1/graphs?orgs=1" \
-H "Authorization: Bearer $SESSION_TOKEN"
3.2 Publish a snapshot#
PUT/v1/graphs/{graphId}
Creates a personal graph, or replaces its entire content, from a snapshot. This is the route the mobile app uses to send a graph to the server. It replaces the whole graph file: it is not a merge.
Request body:
| Field | Type | Required | Description |
|---|---|---|---|
storage |
string | yes | Must be "cloud_readable". The caller has to state explicitly that the graph will be readable by the server. |
snapshot |
string | yes | The snapshot, as a JSON document serialised into a string (see below). |
label |
string | no | Display name of the graph. Every publish restates it: when it is omitted on a later publish, the stored label is cleared. |
baseRevision |
integer | no | The revision the caller last saw. If it is sent and differs from the server's revision, the publish is refused with 409 stale_publish. Send it always: without it, writes made through the live endpoint since your last export are overwritten. |
serverAi |
boolean | no | Sets whether server-side AI may read this graph (see section 3.3). |
pullMerge |
boolean | no | true declares that the publishing device merges an export into its own copy instead of replacing it. Every publish restates this flag; when it is absent or false, session-token writes to the graph are locked (see section 5.8). |
The snapshot is a JSON object with "format": "graphlife.shared-snapshot", a schemaVersion (1 or 2), a nodes array and an edges array, and optionally groups, sources, chunks and provenance. The dependable way to obtain a valid snapshot is to export one (section 3.5) and modify it; the snapshot format is otherwise not specified in this reference.
Response 200:
{ "graphId": "team-kb", "revision": 43, "nodes": 1280, "edges": 3410 }
| Status | Code | Meaning |
|---|---|---|
| 400 | bad_graph_id |
The identifier does not match the allowed pattern. |
| 400 | not_cloud_readable |
storage is missing or not cloud_readable. |
| 400 | missing_snapshot |
snapshot is missing or empty. |
| 400 | bad_snapshot |
The snapshot is malformed or exceeds a snapshot limit (section 1.5). |
| 401 | unauthorized |
No valid session. |
| 404 | not_found |
The identifier belongs to another account, or to an organisation the caller is not in. |
| 409 | stale_publish |
baseRevision does not match the server's revision. Export, merge and retry. |
| 409 | server_authoritative |
The graph belongs to an organisation. Organisation graphs cannot be replaced by a snapshot; write to them through the live endpoint. |
| 500 | snapshot_store_failed |
The server could not store the file. The payload was not at fault; retry later. |
3.3 Update graph settings#
PATCH/v1/graphs/{graphId}
| Field | Type | Description |
|---|---|---|
serverAi |
boolean | Whether server-side AI (model-written answers, extraction, the vector index) may read this graph. Off by default. Turning it off also deletes the graph's vector index. |
pullMerge |
true |
Personal graphs only. Unlocks editing with a session token (section 5.8). Only true is accepted. |
At least one field is required. Only the owner of a personal graph, or a member with the owner role of the organisation, may call this route.
Response 200: {"graphId": "…", "serverAi": true} (each field is echoed only if it was sent).
Errors: 400 invalid, 401 unauthorized, 403 forbidden (not the owner), 404 not_found.
curl -s -X PATCH https://graphlife.example.com/v1/graphs/team-kb \
-H "Authorization: Bearer $SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{"serverAi": true}'
3.4 Remove a graph#
DELETE/v1/graphs/{graphId}
Deletes the graph file, its vector index, its uploaded documents and its live keys. On an organisation graph the caller must be an owner or admin. This cannot be undone.
Response 200: {"status": "ok"}.
Errors: 400 bad_graph_id, 401 unauthorized, 403 forbidden, 404 not_found.
3.5 Export a graph#
GET/v1/graphs/{graphId}/export
Returns the graph as a snapshot. For an organisation graph, the snapshot contains only what the caller may read.
| Query parameter | Description |
|---|---|
merge=1 |
Declares that the caller merges the result into its copy rather than replacing it. Required for a personal graph that has been edited with a session token; with it, retracted entries are objects instead of plain ids. |
Response 200:
{
"revision": 43,
"snapshot": "{\"format\":\"graphlife.shared-snapshot\", …}",
"retracted": ["node-id-1", "node-id-2"]
}
| Field | Description |
|---|---|
revision |
The revision the snapshot was taken at. Send it back as baseRevision when publishing. |
snapshot |
The snapshot, as a JSON document serialised into a string. It holds the graph's current nodes and edges only: soft-deleted rows and uploaded document files are not included. |
retracted |
Node ids removed from a personal graph since it was first published. With merge=1, each entry is {"id": "…", "via": "app" | null}. Always empty for an organisation graph. |
The export is a single response; it is not paginated or streamed.
Errors: 400 bad_graph_id, 401 unauthorized, 404 not_found, 409 app_update_required (a personal graph edited with a session token, requested without merge=1; the body carries an additional detail string).
3.6 Sealed (encrypted) graphs#
PUT /v1/graphs/{graphId}/sealed stores an encrypted graph the server cannot read. GET returns it.
PUT body:
| Field | Type | Required | Description |
|---|---|---|---|
sealed |
string | yes | The encrypted envelope: a JSON document, serialised into a string, whose top level has string fields v and alg. |
label |
string | no | Display name. |
baseRevision |
integer | no | As for a publish: a mismatch is refused. |
PUT response 200: {"revision": 3, "size": 184220} (size is the length of sealed in characters).
GET response 200: {"sealed": "…", "revision": 3, "label": "…", "updatedAt": 1790000000}.
Errors: 400 bad_graph_id, 400 sealed_required, 400 not_sealed (the body is not an envelope), 401 unauthorized, 404 not_found (GET), 409 stale_publish, 413 too_large.
3.7 Create or move an organisation graph#
POST /v1/orgs/{orgId}/graphs — the caller must be an owner or admin of the organisation.
To create a new, empty graph:
| Field | Type | Required | Description |
|---|---|---|---|
storage |
string | yes | Must be "cloud_readable". |
label |
string | yes | 1 to 120 characters. |
Response 200: {"graphId": "…", "label": "…"}. The new graph contains one group, named "Everyone".
To move one of the caller's own personal graphs into the organisation, send {"graphId": "<id>"} instead (storage and label are then ignored). Nodes that were in no group are placed in the organisation's "Everyone" group, and the caller is given membership of every other group the graph already had. The graph's change history and retraction list are discarded, and unless the caller is the organisation's owner, server-side AI is turned off for the graph. Live keys already issued on the graph keep working, but from the next call they are limited to what their creator may do in the organisation. The move cannot be reversed through the API. Response 200: {"graphId": "…"}.
Errors: 400 storage_required, 400 bad_label, 401 unauthorized, 403 forbidden (not an owner or admin), 403 too_many_graphs (creating a graph when the organisation already has 100), 404 not_found (the caller is not a member of the organisation; or, on a move, the graph is not a personal graph of the caller's), 409 group_in_use (the personal graph has a group id the organisation already uses).
curl -s -X POST https://graphlife.example.com/v1/orgs/$ORG_ID/graphs \
-H "Authorization: Bearer $SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{"storage": "cloud_readable", "label": "Company brain"}'