This document describes the REST API structure exposed by Langflow's FastAPI backend. It covers the HTTP endpoints for flow management, execution, authentication, and monitoring. The API follows REST principles and runs on port 7860 by default.
For information about the graph execution engine that powers these endpoints, see Flow Execution Engine. For authentication implementation details, see Authentication and Security. For frontend API consumption patterns, see API Client Layer.
The Langflow backend exposes a RESTful API organized into functional routers defined in src/backend/base/langflow/api/v1/ and v2/. All API routes are typically prefixed with /api/v1/ or /api/v2/. The system supports multiple authentication methods and provides asynchronous operations via job queuing and event streaming.
Sources: src/backend/base/langflow/api/v1/chat.py63 src/backend/base/langflow/api/v1/monitor.py30 src/backend/base/langflow/api/v1/endpoints.py75
The API is organized into specialized routers that manage specific domain entities. The central router is defined in src/backend/base/langflow/api/router.py.
API Router Modules and Route Prefixes
Sources: src/backend/base/langflow/api/v1/chat.py63 src/backend/base/langflow/api/v1/monitor.py30 src/backend/base/langflow/api/v1/endpoints.py75
The core functionality of Langflow is exposed through execution endpoints that build and run graphs.
The /chat router manages the lifecycle of flow execution, including vertex ordering and asynchronous builds.
| Endpoint | Method | Function | Description |
|---|---|---|---|
/build/{flow_id}/vertices | POST | retrieve_vertices_order | Calculates topological sort and returns execution layers src/backend/base/langflow/api/v1/chat.py88-143 |
/build/{flow_id}/flow | POST | build_flow | Initiates a flow build and returns a job ID for polling src/backend/base/langflow/api/v1/chat.py163-178 |
The /base router (in endpoints.py) provides high-level execution wrappers.
simple_run_flow: Orchestrates the conversion of a Flow model into a Graph object, applies tweaks, and executes the graph using run_graph_internal src/backend/base/langflow/api/v1/endpoints.py153-195run_graph_internal: The core bridge that calls graph.arun(). It handles session mapping and converts InputValueRequest into the internal format required by the Vertex components src/backend/base/langflow/processing/process.py26-62Sources: src/backend/base/langflow/api/v1/chat.py88-178 src/backend/base/langflow/api/v1/endpoints.py153-195 src/backend/base/langflow/processing/process.py26-62
The /monitor router provides visibility into execution states and historical chat messages.
Tracks the state and result of individual component builds.
GET /monitor/builds: Retrieves the VertexBuildMapModel for a flow, using get_vertex_builds_by_flow_id which enforces ownership by user_id src/backend/base/langflow/api/v1/monitor.py33-44DELETE /monitor/builds: Deletes build history for a flow, ensuring the user owns the flow src/backend/base/langflow/api/v1/monitor.py50-57Manages the history of interactions stored in MessageTable.
GET /monitor/messages: Filterable retrieval by session_id, sender, or flow_id. Uses SQL JOINs with the Flow table to ensure users only see their own messages src/backend/base/langflow/api/v1/monitor.py85-118PUT /monitor/messages/{message_id}: Updates message content. If the text is modified, it automatically sets edit=True src/backend/base/langflow/api/v1/monitor.py139-166GET /monitor/messages/sessions: Returns unique session IDs associated with the user, excluding internal agentic_ sessions src/backend/base/langflow/api/v1/monitor.py62-82Sources: src/backend/base/langflow/api/v1/monitor.py33-166 src/backend/base/langflow/services/database/models/message/crud.py14-19
Langflow allows dynamic interaction with components through specialized endpoints.
GET /all: Retrieves all available component types, cached and compressed for performance via compress_response src/backend/base/langflow/api/v1/endpoints.py104-118instantiate_class to evaluate the Python code field and create a Component instance src/backend/base/langflow/interface/initialize/loading.py25-51apply_tweaks function allows overriding component parameters at runtime. It specifically protects the code field from being overridden via API tweaks for security src/backend/base/langflow/processing/process.py140-152Sources: src/backend/base/langflow/api/v1/endpoints.py104-118 src/backend/base/langflow/interface/initialize/loading.py25-51 src/backend/base/langflow/processing/process.py140-152
The React frontend manages state and flow data through flowsManagerStore.ts and communicates with the backend via the API controllers.
Natural Language to Code Entity Space: Execution Flow
Natural Language to Code Entity Space: Data Management
Sources: src/frontend/src/stores/flowsManagerStore.ts38-46 src/backend/base/langflow/api/v1/chat.py163-178 src/backend/base/langflow/api/v1/monitor.py85-95 src/backend/base/langflow/processing/process.py26-35