Skip to main content

REST API: Graph

These endpoints drive the core graph execution. All requests require a valid thread_id in config when the server has a checkpointer configured.

Base path: /v1/graph


POST /v1/graph/invoke

Run the graph and return the complete result when all nodes finish.

Request body:

{
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
],
"config": {
"thread_id": "my-thread-1"
}
}
FieldTypeRequiredDescription
messagesarrayyesOne or more messages to append to state before invoking
config.thread_idstringyes (with checkpointer)Conversation identifier

Response:

{
"success": true,
"data": {
"messages": [
{"role": "user", "content": "What is the capital of France?"},
{"role": "assistant", "content": "The capital of France is Paris."}
]
}
}

POST /v1/graph/stream

Run the graph and stream output as server-sent events (SSE).

Request body: Same as /v1/graph/invoke.

Response: Content-Type: text/event-stream

Each event is a JSON-encoded StreamChunk:

data: {"type": "message_chunk", "content": "The capital"}
data: {"type": "message_chunk", "content": " of France is Paris."}
data: {"type": "done"}

StreamChunk types

typeDescription
message_chunkPartial text content
message_startNew message starting
message_endCurrent message complete
tool_callModel requested a tool call
tool_resultTool execution result
doneGraph execution complete

POST /v1/graph/stop

Cancel an in-progress graph execution.

Request body:

{
"thread_id": "my-thread-1",
"config": {}
}

Response:

{
"success": true,
"data": {"status": "stopped", "thread_id": "my-thread-1"}
}

The running graph finishes the current node and then stops. It does not interrupt mid-node.


GET /v1/graph

Get metadata about the loaded graph (node names, edges, state schema summary).

Response:

{
"success": true,
"data": {
"nodes": ["MAIN", "TOOL"],
"entry_point": "MAIN",
"edges": [["TOOL", "MAIN"]]
}
}

GET /v1/graph:StateSchema

Get the JSON schema for the graph's state class.

Response:

{
"success": true,
"data": {
"type": "object",
"properties": {
"context": {"type": "array"},
"user_id": {"type": "string"}
}
}
}

Authentication

When auth is configured, all endpoints require an Authorization header:

Authorization: Bearer <token>

See Authentication for configuration details.