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 including JWT tokens and API keys, and provides asynchronous operations via job queuing and event streaming.
Sources: src/backend/base/langflow/api/router.py67-101 src/backend/base/langflow/api/v1/base.py1-20
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/router.py67-101 src/backend/base/langflow/api/router.py139-162 src/backend/base/langflow/main.py29-30
/api/v1/flows)The src/backend/base/langflow/api/v1/flows.py module manages the CRUD operations for Langflow graphs. It integrates heavily with the AuthorizationService to ensure users only access resources they own or have been shared with.
| Endpoint | Method | Description |
|---|---|---|
/ | POST | Creates a new flow. Uses _new_flow to persist the graph and handle folder assignment. src/backend/base/langflow/api/v1/flows.py107-122 |
/ | GET | Lists flows. Supports pagination via fastapi_pagination and filtering via visible_id_prefilter. src/backend/base/langflow/api/v1/flows.py124-180 |
/{flow_id} | GET | Retrieves a specific flow. Uses AuthorizedReadFlow dependency for RBAC. src/backend/base/langflow/api/v1/flows.py220-227 |
/{flow_id} | PATCH | Updates an existing flow. Handles DeploymentGuardError if the flow is locked for deployment. src/backend/base/langflow/api/v1/flows.py245-268 |
/{flow_id} | DELETE | Removes a flow. Calls cascade_delete_flow to clean up related vertex builds and transactions. src/backend/base/langflow/api/v1/flows.py271-285 |
POST /upload: Accepts a JSON file or ZIP archive containing flow definitions. It uses extract_flows_from_zip and _upsert_flow_list to process bulk imports. src/backend/base/langflow/api/v1/flows.py327-360GET /download/{flow_id}: Generates a JSON export of a flow, stripping secret field values via strip_secret_field_values. src/backend/base/langflow/api/v1/flows.py388-406Sources: src/backend/base/langflow/api/v1/flows.py107-406 src/backend/base/langflow/api/v1/flows_helpers.py37-44
/api/v1/)The src/backend/base/langflow/api/v1/base.py (and previously endpoints.py) module defines several core API endpoints for system configuration and component metadata.
GET /version: Returns the current version information using get_version_info. src/backend/base/langflow/main.py62GET /config: Retrieves the application's configuration. This endpoint returns different data based on authentication status:
feature_flags.GET /all: Retrieves the full component registry (all_types_dict). The response is localized and compressed. src/backend/base/langflow/main.py167Sources: src/backend/base/langflow/api/v1/base.py1-20 src/backend/base/langflow/main.py163-182
/api/v1/users)Managed in src/backend/base/langflow/api/v1/users.py, these endpoints handle the User SQLModel lifecycle.
POST /: Adds a new user. Supports public signup if NEW_USER_SIGNUP is enabled in SettingsService. src/backend/base/langflow/services/database/models/user/crud.py10-20GET /whoami: Returns the UserRead model for the current authenticated user. src/backend/base/langflow/services/auth/utils.py57/api/v1/files)Managed in src/backend/base/langflow/api/v1/files.py, these endpoints handle flow-related artifacts using the StorageService.
POST /upload/{flow_id}: Uploads a file to a specific flow's storage. src/backend/base/langflow/api/v1/files.py83-122GET /download/{flow_id}/{file_name}: Downloads a file from storage using StreamingResponse. src/backend/base/langflow/api/v1/files.py125-154Sources: src/backend/base/langflow/api/v1/files.py29-177 src/backend/base/langflow/services/database/models/user/model.py16
The /api/v2 router introduces the Durable Workflow API, supporting sync, stream, and background execution modes.
POST /api/v2/workflows/{flow_id}: Initiates a workflow. It uses the WorkflowHost to manage the execution lifecycle. src/backend/base/langflow/api/router.py150-159JobService tracks the status of these executions, allowing clients to poll for results or stop running tasks. src/backend/base/langflow/services/jobs/service.py10-30Sources: src/backend/base/langflow/api/v2/workflow.py10-50 src/backend/base/langflow/services/jobs/service.py1-20
Langflow manages its schema via Alembic and a custom DatabaseService.
Natural Language to Code Entity Space: Migration Lock Mechanism
Sources: src/backend/base/langflow/services/database/service.py59-61 src/backend/base/langflow/services/database/service.py132-165 src/backend/base/langflow/services/database/service.py79-112
The backend handles user creation and session management through a multi-layered approach involving the API, Service layer, and Database.
Natural Language to Code Entity Space: User Registration Flow
Sources: src/backend/base/langflow/api/v1/users.py22-65 src/backend/base/langflow/services/database/models/user/model.py16 src/backend/base/langflow/services/utils.py138
Refresh this wiki
This wiki was recently refreshed. Please wait 6 days to refresh again.