Skip to main content

What are threads?

Threads are conversation sessions: one thread = one chat or one agent run with a history of messages and steps. Flowra’s Graphify API is LangGraph-compatible and gives you full control over threads: create a thread, send messages and run the agent (with optional streaming), read back state and history, update metadata (e.g. title), or delete the thread. So you can build your own chat UI or integrate with clients that expect a “thread” + “run” model (e.g. LangGraph). Think of a thread as a container: it holds the conversation state and the runs (each run is one “agent turn” or one streamed response). You create a thread per user or per conversation; then you run the agent on that thread and optionally stream the reply.

Example use cases

  • Chat UI — User opens your app; you create (or load) a thread for them. When they send a message, you call the stream endpoint on that thread; events (message deltas, done) come back over SSE and you render in real time.
  • Support history — Each ticket or customer has a thread. You search threads by metadata (e.g. userId, ticketId), load the thread, and show or continue the conversation.
  • LangGraph integration — If you use LangGraph or a compatible client, the thread is the conversation checkpoint; you run the graph on the thread and get state/history via the API.

How it works

  1. Create a thread (or search for existing ones by metadata).
  2. Run the agent on the thread — POST .../runs/stream with the new message; you get SSE events (deltas, tool calls, done). Or use a non-streaming run if you prefer.
  3. State and history — Get current thread state (messages, checkpoint) or full history (past runs, steps). Update thread metadata (e.g. title); generate title from content; delete when the conversation is done.
All endpoints are under the Graphify API prefix (e.g. /graphify/threads). See the sections below for each endpoint.

API endpoints

Search threads

POST /api/v1/graphify/threads/search searches threads by metadata (e.g. user id, tags). Request body: SearchThreadsDto. Use to list or filter threads in a chat UI or dashboard.

Create and get thread

  • POST /api/v1/graphify/threads — Create a new thread. Body: CreateThreadDto (optional metadata). Returns the new thread.
  • GET /api/v1/graphify/threads/{thread_id} — Get a thread’s metadata and info. Use to load a conversation before continuing.
  • PATCH /api/v1/graphify/threads/{thread_id} — Update thread metadata (e.g. title or custom fields). Body: UpdateThreadDto.

Generate thread title

POST /api/v1/graphify/threads/{thread_id}/generate-title generates a short title for the thread from its content using AI. Use to show a meaningful title in the thread list.

Thread state

GET /api/v1/graphify/threads/{thread_id}/state returns the current state of the thread (e.g. latest messages, checkpoint). Use to resume a conversation or inspect state for debugging.

Run and stream

POST /api/v1/graphify/threads/{thread_id}/runs/stream runs the agent/chat for this thread and streams the response via Server-Sent Events (SSE). Use for real-time chat UIs; events include message deltas and run status. Request body: StreamThreadRunDto. POST /api/v1/graphify/threads/{thread_id}/runs/{run_id}/cancel stops a running execution (e.g. when the user clicks stop). Optional query: wait=true, action=interrupt or rollback.

Thread history

POST /api/v1/graphify/threads/{thread_id}/history returns the execution history for a thread: past runs, steps, and state snapshots. Body: ThreadHistoryDto. Use to show a timeline or debug a conversation.

Delete thread

DELETE /api/v1/graphify/threads/{thread_id} permanently deletes a thread and its conversation history. It cannot be recovered.