Accounts and access
7. API keys
An API key (called a live key in the product) is the credential for machine access to graph content. Each key:
- is bound to one graph, chosen when it is minted (a key on a personal graph that holds the
create_graphtool also reaches the graphs it creates with it); - carries a scope: which tools it may call and which part of the graph it may see;
- has an optional expiry (
expiresAt); without one it works until it is revoked or its graph is removed from the server; - can be rotated (given a new secret) and edited (label, expiry, added tools) without changing its id (section 7.5);
- is managed with a session token, and used with its own
glk_token.
Keys are minted, listed, edited and revoked by a signed-in account. There is no way to mint a key with another key; a key whose scope holds rotate_key can only replace its own secret. On an organisation graph, an admin can also mint a key for a service account, so that the key is bounded by the service account's role and groups rather than by a person's and keeps working when that person leaves; see Service accounts.
Who may manage keys:
| Graph type | Mint, list, revoke |
|---|---|
| Personal graph | The graph's owner. The owner sees and revokes only the keys they minted. |
| Organisation graph | Org admins (owner or admin). They see and may revoke every key on the graph, whoever minted it. |
7.1 The scope object#
| Field | Type | Default | Meaning |
|---|---|---|---|
tools |
array of strings | the read tools | The tool names the key may call. See the table below. |
groups |
array of group ids | [] |
The groups whose nodes the key may see. Group ids, not names. |
allNodes |
boolean | false |
true lets the key see every node of the graph regardless of group. Not allowed on an organisation graph. |
level |
"full" or "listed" |
"full" |
full returns a node's fields. listed returns existence only: kind, a masked label, and a document's type. |
nodeIds |
array of node ids | [] |
When non-empty, restricts the key to exactly these nodes. A key restricted this way cannot create nodes. |
redactProps |
array of strings | [] |
Property names removed from every node the key reads (for example ["phone"]). |
maxNodes |
integer | 200 | Upper bound on rows returned per call. On an organisation graph the effective value is never higher than 200. |
writeGroup |
group id | (none) | The group new nodes created by this key are filed into. Must be one of groups; otherwise it is ignored. With exactly one group in groups, that group is used automatically. |
kinds |
array of strings | [] |
Legacy: the node subtypes the key may see. When groups is also given, a node must satisfy both. Prefer groups. |
Important rules:
- Always send
groups(even as an empty array) orlevel. A scope object that names neither is interpreted as a legacy scope from an older version of the product: such a key never reads nodes whose subtype ishealth,capture,pageordocument, whatever else the scope says. This is easy to trigger by accident with a minimal scope such as{"tools":[...]}. Sending"legacy": truehas the same effect. - Deny by default on a personal graph. A scope with empty
groups, emptykinds,allNodesnot set and nonodeIdsauthenticates successfully and sees no nodes. - On an organisation graph an empty
groupslist does not mean "nothing". A key whose scope names no groups reads through every group its minter currently holds on that graph (see the organisation rules underPOST /v1/graphs/{graphId}/keys). List the groups explicitly to make a key narrower than its minter. - An unrecognised
levelvalue is read asfull. - The scope object is stored as sent, and the listing returns it as sent. Tool names are not validated at mint time; an unknown tool name simply never matches a call.
- Unknown fields are ignored on a personal graph. In particular, a caller cannot grant itself owner-level access through this object.
Tool names:
| Set | Tools |
|---|---|
| Read tools | stats, search, search_prose, node, neighbors, subgraph, paths |
| Write tools | add_to_graph, add_capture, update_node, set_groups, create_group, delete_node, delete_edge |
| Account tool | create_graph (creates a new graph on the minting account; not allowed on an organisation graph) |
| List tools | list_nodes, list_edges (page through every node or edge the key can see). Never granted by default; name them explicitly. |
| Integration tools | changes, export, extract, webhooks, rotate_key. Each opens a route rather than a graph tool (change feed, export, extraction, the key's own webhooks, replacing its own secret); see Routes that accept a key. Never granted by default. |
Some tools have no name of their own in a scope and are governed by others: context and ask require both search and subgraph; get_document and get_nodes require node; list_graphs and list_groups require stats; add_document and add_edge require add_to_graph; update_group requires create_group; end_edge and restore_edge require delete_edge; restore_node requires delete_node. The tools themselves are described in graph data and MCP tools.
POST/v1/graphs/{graphId}/keys#
Mints a key. Session: graph owner, or org admin for an organisation graph.
| Body field | Type | Required | Meaning |
|---|---|---|---|
scope |
object | yes | See section 7.1. |
label |
string | no | A name for the key, shown in listings. |
expiresAt |
integer | no | Unix time in seconds after which the key stops working. Must be after now and at most 10 years ahead. Omit for a key that does not expire. |
serviceAccount |
string | no | Organisation graph only: the id of an active service account to mint the key for. See Service accounts. |
curl -X POST https://graphlife.example.com/v1/graphs/$GRAPH_ID/keys \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
-d '{
"label": "CRM read-only sync",
"scope": {
"tools": ["stats","search","search_prose","node","neighbors","subgraph","paths"],
"groups": ["4f0c2f6e-1d2b-4a55-8a3e-9d2f6b1c7e21"],
"level": "full",
"maxNodes": 200
}
}'
Response: 200 OK
{
"keyId": "c7a1e0d4-52b9-4f0e-b1a2-6f3d9e8c4b77",
"token": "glk_Zk3...",
"graphId": "9a8b7c6d-5e4f-4a3b-2c1d-0e9f8a7b6c5d",
"expiresAt": null
}
token is shown only in this response.
Additional rules on an organisation graph: a key can never reach further than the person who minted it.
- The scope may not set
allNodes. - Its
toolsmust be within the tools of the minter's role (section 10.1) and may not includecreate_graph. - Its
groupsmust all be groups the minter currently holds on that graph. Ifgroupsis empty, the key uses all of the minter's groups. - It may not carry
"ownerAccess": true. - The key is re-checked against the minter's current role and groups on every call. If the minter is demoted or loses a group, the key narrows with them; if the minter leaves the organisation or their account is deleted, the key stops working (
404 not_found). - A key minted for a service account follows the same rules against the service account's role and groups instead, must name its
groupsexplicitly, and may name only groups the minting admin also holds (an owner may name any).
| Status | code |
When |
|---|---|---|
| 400 | missing_scope |
scope is missing or not an object. |
| 400 | bad_expiry |
expiresAt is not after now, or more than 10 years ahead. |
| 400 | bad_args |
A field has the wrong type (for example expiresAt not a number). |
| 400 | scope_too_wide |
Organisation graph: allNodes, ownerAccess, a tool outside the minter's (or service account's) role, or create_graph. |
| 400 | groups_required |
A key for a service account names no groups. |
| 401 | unauthorized |
No valid session. |
| 403 | forbidden |
Organisation graph and the caller is a member or guest. |
| 404 | not_found |
No such graph, or not the caller's; or serviceAccount is not an active service account of the graph's organisation. |
| 409 | scope_exceeds_yours |
Organisation graph: the scope names a group the minter (or the service account) does not hold. |
GET/v1/graphs/{graphId}/keys#
Lists the keys on a graph, newest first, including revoked ones. Session: graph owner (own keys only), or org admin (all keys). The list is not paginated.
{
"keys": [
{
"keyId": "c7a1e0d4-52b9-4f0e-b1a2-6f3d9e8c4b77",
"label": "CRM read-only sync",
"scope": { "tools": ["..."], "groups": ["..."], "level": "full", "maxNodes": 200 },
"createdAt": 1764201600,
"revokedAt": null,
"lastUsedAt": 1764288000,
"useCount": 412,
"expiresAt": null,
"rotatedAt": null,
"mintedBy": "0b6f2c1e-8a41-4d0f-9c55-2f1f0c9d7a10",
"principal": { "type": "user", "id": "0b6f2c1e-8a41-4d0f-9c55-2f1f0c9d7a10" }
}
]
}
mintedBy is the account that minted the key (null for keys minted before this was recorded). principal is whose role and groups bound the key: {"type": "user", "id": …} for a person, or {"type": "service", "id": …, "name": …} for a service account. The token is never returned. On a personal graph the route answers 200 with an empty list for a graph the caller does not own. On an organisation graph: 404 not_found for a non-member, 403 forbidden for a member or guest.
DELETE/v1/graphs/{graphId}/keys/{keyId}#
Revokes a key. Session: graph owner (own keys), or org admin (any key on the graph). Takes effect on the key's next call.
Response: 200 OK with {"status":"ok"}. The route is idempotent and answers the same for a key id that does not exist. On an organisation graph: 404 not_found for a non-member, 403 forbidden for a member or guest.
7.5 Editing and rotating a key#
Three routes change an existing key without changing its id. They are described in full in API keys: expiry, rotation, editing.
| Route | Auth | Purpose |
|---|---|---|
PATCH/v1/graphs/{graphId}/keys/{keyId} |
Session (graph owner, or org admin) | Changes the key's label and expiresAt (0 clears the expiry), and adds tools from the list and integration sets (addTools). Nothing else in the scope changes, and no tool is taken away. Returns the key as the listing shows it. |
POST/v1/graphs/{graphId}/keys/{keyId}/rotate |
Session (graph owner, or org admin) | Gives the key a new secret. Optional overlapSeconds (0 to 7 days, default 0) keeps the previous secret working for that long. Returns keyId, token (shown once), graphId and previousValidUntil. 409 revoked for a revoked key. |
POST/v1/keys/rotate |
The key itself, with rotate_key in its scope |
The key replaces its own secret. overlapSeconds is 60 seconds to 7 days, default one hour. Only the current secret may rotate; the previous one answers 403 previous_secret. |
On an organisation graph, an owner may rotate or edit any key. An admin may rotate or edit their own keys, and another key only when they hold every group it reaches (409 scope_exceeds_yours otherwise). Revoking is open to any owner or admin.
7.6 Using a key#
curl -X POST https://graphlife.example.com/v1/live \
-H 'Authorization: Bearer glk_Zk3...' \
-H 'Content-Type: application/json' \
-d '{"tool":"stats","args":{}}'
Authentication outcomes at the graph endpoints (POST /v1/live, POST /v1/live/{tool}, GET /v1/live/tools, POST /v1/live/mcp):
| Status | code |
When |
|---|---|---|
| 401 | unauthorized |
No token, or a token that is not a key, an OAuth token or a valid session. |
| 401 | key_expired |
The key is past its expiresAt. |
| 401 | invalid_token |
An OAuth access token that is unknown, revoked or expired. |
| 403 | revoked |
The key has been revoked. |
| 403 | invalid_token |
An OAuth access token issued for a different resource. |
| 403 | forbidden |
The credential's scope does not allow the tool that was called. |
| 429 | rate_limited |
The credential's allowance in section 4 is used up: the key's or token's own, or the account's for a session. |
| 404 | not_found |
Organisation graph: the key's principal (the minter, or the service account) no longer has any reach there. |
A key's reach cannot be narrowed after minting: editing can only add tools from the list and integration sets. To narrow a key, mint a new one and revoke the old one. Unpublishing a personal graph deletes its keys.