Graph data
4. Live keys
A live key is the credential a program uses on the live endpoint. Keys are managed with a session token. On an organisation graph the caller must be an owner or admin.
| Method | Path | Purpose |
|---|---|---|
| POST | /v1/graphs/{graphId}/keys |
Create a key |
| GET | /v1/graphs/{graphId}/keys |
List keys |
| DELETE | /v1/graphs/{graphId}/keys/{keyId} |
Revoke a key |
| PATCH | /v1/graphs/{graphId}/keys/{keyId} |
Edit a key: label, expiry, added tools |
| POST | /v1/graphs/{graphId}/keys/{keyId}/rotate |
Give a key a new secret |
Expiry, rotation (including a key rotating its own secret with POST /v1/keys/rotate), editing and keys for service accounts are described in API keys: expiry, rotation, editing and Service accounts.
4.1 Create a key#
Request body: {"label": "ERP sync", "scope": { … }}. scope is required. Optional fields: expiresAt (epoch seconds, after now and at most ten years out, otherwise 400 bad_expiry) and, on an organisation graph, serviceAccount.
| Scope field | Type | Default | Description |
|---|---|---|---|
tools |
array of strings | the read operations (stats, search, search_prose, node, neighbors, subgraph, paths) |
The operations the key may call. See section 5.2 for the names that can appear here. |
groups |
array of group ids | [] |
The groups whose nodes the key may see. |
allNodes |
boolean | false |
The key sees every node, regardless of groups. Not allowed on an organisation graph. |
level |
"full" or "listed" |
"full" |
listed reduces everything the key sees to existence stubs. |
kinds |
array of strings | [] |
Restricts the key to these subtypes (matched against props.subtype). |
nodeIds |
array of strings | [] |
Restricts the key to exactly these nodes. A key restricted this way cannot create nodes. |
redactProps |
array of strings | [] |
Property keys removed from every node the key reads. |
maxNodes |
integer | 200 |
The maximum number of rows any one read operation returns to this key. On a personal graph the value you send is stored as given; on an organisation graph the effective value never exceeds 200. |
writeGroup |
group id | — | The group that nodes created by this key are filed into. A value that is not one of groups is silently ignored. When the key holds exactly one group, that group is used. |
A key with no groups, no kinds, no nodeIds and without allNodes sees no nodes. A key can create nodes only if it has a group to file them into, or allNodes.
On a personal graph the scope is stored exactly as sent and is not validated: an unknown name in tools, or a group id that does not exist, is accepted and simply grants nothing. Check a new key with a stats call before handing it out.
Include node in tools for any key that writes. The operations update_node, set_groups, delete_node, delete_edge, get_document, and add_document with a nodeId, first read the node they act on, and answer 403 forbidden to a key whose scope lacks node.
Always send groups (an empty array if none) or level. A scope that names neither is treated as a key from an older version and is permanently barred from the subtypes health, capture, page and document.
Response 200: {"keyId": "…", "token": "glk_…", "graphId": "…", "expiresAt": null}. The token is shown once; the server stores only a hash.
| Status | Code | Meaning |
|---|---|---|
| 400 | missing_scope |
scope is missing or not an object. |
| 400 | bad_expiry |
expiresAt is not after now, or is more than ten years out. |
| 400 | scope_too_wide |
Organisation graph: the scope asks for allNodes, for an operation the caller's role does not have, or for create_graph. |
| 401 | unauthorized |
No valid session. |
| 403 | forbidden |
Organisation graph: the caller is not an owner or admin. |
| 404 | not_found |
The graph is not the caller's. |
| 409 | scope_exceeds_yours |
Organisation graph: the scope names a group the caller does not hold. |
curl -s -X POST https://graphlife.example.com/v1/graphs/team-kb/keys \
-H "Authorization: Bearer $SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"label": "ERP sync",
"scope": {
"tools": ["stats","search","node","neighbors","subgraph","paths",
"search_prose","add_to_graph","update_node"],
"groups": ["GROUP_ID"],
"level": "full"
}
}'
GROUP_ID is the id of an existing group in the graph. Group ids are returned by the list_groups and create_group operations (section 5) and by the canvas route (section 13.2). On an organisation graph only an owner or admin can create keys.
4.2 List and revoke#
GET response 200:
{
"keys": [
{
"keyId": "…", "label": "ERP sync", "scope": { … },
"createdAt": 1790000000, "revokedAt": null,
"lastUsedAt": 1790003600, "useCount": 512,
"expiresAt": null, "rotatedAt": null, "mintedBy": "…",
"principal": { "type": "user", "id": "…" }
}
]
}
On a personal graph only the caller's own keys are listed; on an organisation graph, every key on the graph. Revoked keys remain in the list with revokedAt set. The list is not paginated, and is ordered newest first. principal says whose role and groups bound the key: "type": "user" for a person, "service" (with a name) for a service account.
DELETE response 200: {"status": "ok"}. The response is the same whether or not the key existed.