graphlife Docs graphlife.app

Graph data

10. Extraction: turning text into graph data on the server

Extraction sends a text to a language model, which proposes nodes and relationships; the proposal is then committed to the graph, either after a person approves it or directly.

These routes take a session token, and the caller must be the owner of a personal graph or an owner or admin of the organisation. A live key whose scope holds extract may also submit a text and list the jobs it submitted (see Extraction); approving, rejecting, undoing and retrying stay with a person. A program that already has structured data should use add_to_graph on the live endpoint instead.

Extraction is off by default. A job is accepted only when a model key is available (as in section 8, rule 2) and the graph's owner has turned server-side AI on. GET /health reports "extraction": true when a model key could be used.

Method Path Purpose
POST /v1/graphs/{graphId}/extract Submit a text
GET /v1/graphs/{graphId}/extract/jobs List jobs
POST /v1/graphs/{graphId}/extract/jobs/{jobId}/approve Commit a reviewed proposal
POST /v1/graphs/{graphId}/extract/jobs/{jobId}/reject Discard a proposal
POST /v1/graphs/{graphId}/extract/jobs/{jobId}/undo Take back a committed extraction
POST /v1/graphs/{graphId}/extract/jobs/retry Requeue failed jobs

Errors common to all six: 401 unauthorized, 403 forbidden (not an owner or admin), 404 not_found.

10.1 Submit a text#

POST/v1/graphs/{graphId}/extract

Field Type Default Description
text string — Required. The text to read. Plain text only: this route does not accept files. Text beyond EXTRACT_MAX_CHARS characters (default 100,000) is silently cut off.
gate "review" or "direct" "review" review holds the proposal until it is approved. direct commits it as soon as the model answers.
referenceDate string — The date the text was written, so relative dates ("last week") resolve correctly. At most 32 characters.

Response 200: {"jobId": "…"}. The job runs in the background; poll the job list for its outcome. There is no callback.

On an organisation graph, new nodes are filed into the caller's own write group.

Status Code Meaning
400 invalid text is missing or empty, gate is unknown, or referenceDate is malformed.
403 forbidden Organisation graph: the caller has no write group.
409 server_ai_off The graph's owner has not turned server-side AI on.
409 not_queued The job could not be queued.
409 app_update_required Personal graph, gate: "direct", and session writes are locked (section 5.8).
503 extraction_not_configured No model key is available.

The checks run in this order: 503 extraction_not_configured, then 409 server_ai_off, then 400 invalid. Each submission creates a new job; submitting the same text twice extracts it twice.

curl -s https://graphlife.example.com/v1/graphs/team-kb/extract \
  -H "Authorization: Bearer $SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"text": "Minutes of the 12 May meeting: …", "gate": "review", "referenceDate": "2026-05-12"}'

10.2 List jobs#

GET/v1/graphs/{graphId}/extract/jobs

Query parameter Description
status Optional filter: queued, running, review, done or failed. Any other value returns 400 invalid.

Response 200:

{
  "jobs": [
    {
      "jobId": "…", "status": "review",
      "source": "paste", "sourceUri": "paste:…", "gate": "review",
      "attempts": 0, "error": null, "nextAt": 1790001000,
      "createdAt": 1790000990, "updatedAt": 1790001004,
      "usage": { "input_tokens": 2104, "output_tokens": 611 },
      "proposed": { "entities": [ … ], "relations": [ … ] }
    }
  ]
}
Field Description
status queued, running, review (waiting for approval), done or failed.
error A short code on a failed or special outcome: rejected, superseded, undone, split, source_gone, graph_gone, server_ai_off, not_configured, key_unreadable, auth, no_output, oversized_output, budget, network, timeout, or http_<status> for a refusal by the model provider. A job that failed for an unexpected reason carries a longer free-text message. error can be set on a job whose status is done (undone, split, source_gone) or queued (the reason for the last retry, or budget), so read it together with status.
attempts The number of failed runs so far.
nextAt When a queued job is due to run.
proposed Only while status is review: the proposed entities and relations, in the add_to_graph shape.
counts, sourceId After a commit: {"nodesCreated", "nodesMerged", "edgesCreated"} and the id of the stored source.
usage Model token usage, when a model call was made.

The response is drawn from the 200 most recently updated jobs for the graph, most recently updated first; there is no pagination and no route to fetch one job by id. The submitted text is never returned. On an organisation graph, a caller sees only jobs filed into groups they hold, so fewer than 200 may be returned. Jobs with the status done or failed are deleted 30 days after their last update.

10.3 Approve, reject, undo, retry#

Approve — POST …/jobs/{jobId}/approve. Optional body: {"entities": [ … ], "relations": [ … ]} to replace either half of the proposal with an edited version. At most 300 entities. Response 200: {"jobId", "sourceId", "counts": {"nodesCreated", "nodesMerged", "edgesCreated"}}. Errors: 400 oversized_output, 409 not_in_review, 409 superseded, 409 source_gone, 409 app_update_required, 409 graph_moved.

Reject — POST …/jobs/{jobId}/reject. Nothing was committed, so nothing is undone; the proposal and its text are dropped. Response 200: {"jobId", "status": "rejected"}. Errors: 409 not_in_review.

Undo — POST …/jobs/{jobId}/undo. Removes what a committed extraction added: its source and every fact only that source supports. Nodes that someone has since edited through the live endpoint are kept. Removed nodes are soft-deleted and can be brought back with restore_node. Response 200: {"jobId", "nodesRemoved": 3, "edgesRemoved": 5}. Errors: 409 nothing_to_undo (the job is not done, or was already undone), 409 app_update_required, 409 graph_moved.

Retry — POST …/jobs/retry. Requeues the failed jobs within the caller's reach that can still run. A failed job created by POST …/extract cannot be retried: its text is deleted when the job fails, so the text has to be submitted again. Because that route is the only way to create an extraction job through this API, requeued is 0 for jobs created through it. Transient failures are retried automatically before a job is marked failed (section 10.4). Response 200: {"requeued": 0}.

Approve, reject and undo answer 404 not_found for an unknown job id, and for a job on an organisation graph that is filed into a group the caller does not hold.

10.4 Processing behaviour#

Topic Behaviour
Queue Jobs run in the background inside the server process, polled every JOBS_POLL_SECONDS seconds (default 5) and started immediately on submission.
Model Selected with the EXTRACT_MODEL environment variable. The provider is the same as for questions (section 8).
Concurrency Extraction jobs run one at a time, in a single server process. Jobs that were running when the server stopped are queued again when it starts.
Transient failures Retried with a delay starting at 30 seconds and doubling, up to one hour, for at most EXTRACT_MAX_ATTEMPTS attempts (default 5).
Long texts When the model's answer is cut off and the text is longer than 4,000 characters, the job is split into two halves that run as separate jobs. The parent job finishes with error: "split".
Budget When the operator's key is used and the monthly token budget would be exceeded, the job is deferred to the start of the next month (error: "budget", status queued).
Output size A proposal with more than 300 entities fails with oversized_output.