Skip to main content

API examples

This page provides examples and practices for managing Langflow using the Langflow API.

The Langflow API's OpenAPI spec can be viewed and tested at your Langflow deployment's docs endpoint. For example, http://127.0.0.1:7860/docs.

Export values (optional)

You might find it helpful to set the following environment variables:

  • Export your Langflow URL in your terminal. Langflow starts by default at http://127.0.0.1:7860.

_10
export LANGFLOW_URL="http://127.0.0.1:7860"

  • Export the flow-id in your terminal. The flow-id is found in the API pane or in the flow's URL.

_10
export FLOW_ID="359cd752-07ea-46f2-9d3b-a4407ef618da"

  • Export the folder-id in your terminal. To find your folder ID, call the Langflow /api/v1/folders/ endpoint for a list of folders.

_10
curl -X 'GET' \
_10
"$LANGFLOW_URL/api/v1/folders/" \
_10
-H 'accept: application/json'

Export the folder-id as an environment variable.


_10
export FOLDER_ID="1415de42-8f01-4f36-bf34-539f23e47466"

  • Export the Langflow API key as an environment variable. To create a Langflow API key, run the following command in the Langflow CLI.

_10
langflow api-key

Export the generated API key as an environment variable.


_10
export LANGFLOW_API_KEY="sk-..."

The examples in this guide use environment variables for these values.

Build

Use the /build endpoint to build vertices and flows.

Build flow

This example builds a flow with a given flow_id.

LLM chat responses are streamed back as token events until the end event closes the connection.


_10
curl -X 'POST' \
_10
"$LANGFLOW_URL/api/v1/build/$FLOW_ID/flow" \
_10
-H 'accept: application/json' \
_10
-H 'Content-Type: application/json' \
_10
-H "x-api-key: $LANGFLOW_API_KEY" \
_10
-d '{"message": "hello, how are you doing?"}'

This output is abbreviated, but the order of events illustrates how Langflow runs components.

  1. Langflow first sorts the vertices by dependencies (edges) in the vertices_sorted event:

_10
ChatInput-8VNJS → Prompt-CDhMB → OpenAIModel-mXCyV → ChatOutput-Up0tW

  1. The Chat Input component receives user input in the add_message event.
  2. The Prompt component is built and executed with the received input in the end_vertex event.
  3. The Open AI model's responses stream as token events. The token event represents individual pieces of text as they're generated by an LLM.
  4. The clean end event tells you the flow executed with no errors. If your flow executes with errors, the error event handler prints the errors to the playground.

You can also pass values for start_component_id and stop_component_id in the body of the command to control where the flow run will start and stop. For example, to stop flow execution at the Open AI model component, run the following command:


_10
curl -X 'POST' \
_10
"$LANGFLOW_URL/api/v1/build/$FLOW_ID/flow" \
_10
-H 'accept: application/json' \
_10
-H 'Content-Type: application/json' \
_10
-H "x-api-key: $LANGFLOW_API_KEY" \
_10
-d '{"stop_component_id": "OpenAIModel-Uksag"}'

Flows

Use the /flows endpoint to create, read, update, and delete flows.

Create flow

Create a new flow.


_22
curl -X 'POST' \
_22
"$LANGFLOW_URL/api/v1/flows/" \
_22
-H 'accept: application/json' \
_22
-H 'Content-Type: application/json' \
_22
-d '{
_22
"name": "string2",
_22
"description": "string",
_22
"icon": "string",
_22
"icon_bg_color": "#FF0000",
_22
"gradient": "string",
_22
"data": {},
_22
"is_component": false,
_22
"updated_at": "2024-12-30T15:48:01.519Z",
_22
"webhook": false,
_22
"endpoint_name": "string",
_22
"tags": [
_22
"string"
_22
],
_22
"locked": false,
_22
"user_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
_22
"folder_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
_22
}'

Read flows

Retrieve a list of flows with pagination support.


_10
curl -X 'GET' \
_10
"$LANGFLOW_URL/api/v1/flows/?remove_example_flows=false&components_only=false&get_all=true&header_flows=false&page=1&size=50" \
_10
-H 'accept: application/json'

To retrieve only the flows from a specific folder, pass folder_id in the query string.


_10
curl -X 'GET' \
_10
"$LANGFLOW_URL/api/v1/flows/?remove_example_flows=true&components_only=false&get_all=false&folder_id=$FOLDER_ID&header_flows=false&page=1&size=1" \
_10
-H 'accept: application/json'

Read flow

Read a specific flow by its ID.


_10
curl -X 'GET' \
_10
"$LANGFLOW_URL/api/v1/flows/$FLOW_ID" \
_10
-H 'accept: application/json'

Update flow

Update an existing flow by its ID.

This example changes the value for endpoint_name from a random UUID to my_new_endpoint_name.


_12
curl -X 'PATCH' \
_12
"$LANGFLOW_URL/api/v1/flows/$FLOW_ID" \
_12
-H 'accept: application/json' \
_12
-H 'Content-Type: application/json' \
_12
-d '{
_12
"name": "string",
_12
"description": "string",
_12
"data": {},
_12
"folder_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
_12
"endpoint_name": "my_new_endpoint_name",
_12
"locked": true
_12
}'

Delete flow

Delete a specific flow by its ID.


_10
curl -X 'DELETE' \
_10
"$LANGFLOW_URL/api/v1/flows/$FLOW_ID" \
_10
-H 'accept: application/json'

Create flows

Create multiple new flows.


_44
curl -X 'POST' \
_44
"$LANGFLOW_URL/api/v1/flows/batch/" \
_44
-H 'accept: application/json' \
_44
-H 'Content-Type: application/json' \
_44
-d '{
_44
"flows": [
_44
{
_44
"name": "string",
_44
"description": "string",
_44
"icon": "string",
_44
"icon_bg_color": "string",
_44
"gradient": "string",
_44
"data": {},
_44
"is_component": false,
_44
"updated_at": "2024-12-30T18:36:02.737Z",
_44
"webhook": false,
_44
"endpoint_name": "string",
_44
"tags": [
_44
"string"
_44
],
_44
"locked": false,
_44
"user_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
_44
"folder_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
_44
},
_44
{
_44
"name": "string",
_44
"description": "string",
_44
"icon": "string",
_44
"icon_bg_color": "string",
_44
"gradient": "string",
_44
"data": {},
_44
"is_component": false,
_44
"updated_at": "2024-12-30T18:36:02.737Z",
_44
"webhook": false,
_44
"endpoint_name": "string",
_44
"tags": [
_44
"string"
_44
],
_44
"locked": false,
_44
"user_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
_44
"folder_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
_44
}
_44
]
_44
}'

Upload flows

Upload flows from a file.

This example uploads a local file named agent-with-astra-db-tool.json.


_10
curl -X 'POST' \
_10
"$LANGFLOW_URL/api/v1/flows/upload/?folder_id=$FOLDER_ID" \
_10
-H 'accept: application/json' \
_10
-H 'Content-Type: multipart/form-data' \
_10
-F 'file=@agent-with-astra-db-tool.json;type=application/json'

To specify a target folder for the flow, include the query parameter folder_id. The target folder_id must already exist before uploading a flow. Call the /api/v1/folders/ endpoint for a list of available folders.


_10
curl -X 'POST' \
_10
"$LANGFLOW_URL/api/v1/flows/upload/?folder_id=$FOLDER_ID" \
_10
-H 'accept: application/json' \
_10
-H 'Content-Type: multipart/form-data' \
_10
-F 'file=@agent-with-astra-db-tool.json;type=application/json'

Download all flows

Download all flows as a ZIP file.

This endpoint downloads a ZIP file containing flows for all flow-id values listed in the command's body.


_10
curl -X 'POST' \
_10
"$LANGFLOW_URL/api/v1/flows/download/" \
_10
-H 'accept: application/json' \
_10
-H 'Content-Type: application/json' \
_10
-d '[
_10
"e1e40c77-0541-41a9-88ab-ddb3419398b5", "92f9a4c5-cfc8-4656-ae63-1f0881163c28"
_10
]' \
_10
--output langflow-flows.zip

Read basic examples

Retrieve a list of basic example flows.


_10
curl -X 'GET' \
_10
"$LANGFLOW_URL/api/v1/flows/basic_examples/" \
_10
-H 'accept: application/json'

Monitor

Use the /monitor endpoint to monitor and modify messages passed between Langflow components, vertex builds, and transactions.

Get Vertex builds

Retrieve Vertex builds for a specific flow.


_10
curl -X 'GET' \
_10
"$LANGFLOW_URL/api/v1/monitor/builds?flow_id=$FLOW_ID" \
_10
-H 'accept: application/json'

Delete Vertex builds

Delete Vertex builds for a specific flow.


_10
curl -X 'DELETE' \
_10
"$LANGFLOW_URL/api/v1/monitor/builds?flow_id=$FLOW_ID" \
_10
-H 'accept: */*'

Get messages

Retrieve messages with optional filters.


_10
curl -X 'GET' \
_10
'http://127.0.0.1:7860/api/v1/monitor/messages' \
_10
-H 'accept: application/json'

You can filter messages by flow_id, session_id, sender, and sender_name. Results can be ordered with the order_by query string.

This example retrieves messages sent by Machine and AI in a given chat session (session_id) and orders the messages by timestamp.


_10
curl -X "GET" \
_10
"$LANGFLOW_URL/api/v1/monitor/messages?flow_id=$FLOW_ID&session_id=01ce083d-748b-4b8d-97b6-33adbb6a528a&sender=Machine&sender_name=AI&order_by=timestamp" \
_10
-H "accept: application/json"

Delete messages

Delete specific messages by their IDs.

This example deletes the message retrieved in the previous Get messages example.


_10
curl -v -X 'DELETE' \
_10
'$LANGFLOW_URL/api/v1/monitor/messages' \
_10
-H 'accept: */*' \
_10
-H 'Content-Type: application/json' \
_10
-d '[
_10
"1c1d6134-9b8b-4079-931c-84dcaddf19ba"
_10
]'

To delete multiple messages, list the IDs within the array.


_10
curl -v -X 'DELETE' \
_10
'$LANGFLOW_URL/api/v1/monitor/messages' \
_10
-H 'accept: */*' \
_10
-H 'Content-Type: application/json' \
_10
-d '["MESSAGE_ID_1", "MESSAGE_ID_2"]'

Update message

Update a specific message by its ID.

This example updates the text value of message 3ab66cc6-c048-48f8-ab07-570f5af7b160.


_10
curl -X 'PUT' \
_10
"$LANGFLOW_URL/api/v1/monitor/messages/3ab66cc6-c048-48f8-ab07-570f5af7b160" \
_10
-H 'accept: application/json' \
_10
-H 'Content-Type: application/json' \
_10
-d '{
_10
"text": "testing 1234"
_10
}'

Update session ID

Update the session ID for messages.

This example updates the session_ID value 01ce083d-748b-4b8d-97b6-33adbb6a528a to different_session_id.


_10
curl -X 'PATCH' \
_10
"$LANGFLOW_URL/api/v1/monitor/messages/session/01ce083d-748b-4b8d-97b6-33adbb6a528a?new_session_id=different_session_id" \
_10
-H 'accept: application/json'

Delete messages by session

Delete all messages for a specific session.


_10
curl -X 'DELETE' \
_10
'$LANGFLOW_URL/api/v1/monitor/messages/session/different_session_id_2' \
_10
-H 'accept: */*'

Get transactions

Retrieve all transactions (interactions between components) for a specific flow.


_10
curl -X 'GET' \
_10
'$LANGFLOW_URL/api/v1/monitor/transactions?flow_id=$FLOW_ID&page=1&size=50' \
_10
-H 'accept: application/json'

Folders

Use the /folders endpoint to create, read, update, and delete folders.

Folders store your flows and components.

Read folders

Get a list of Langflow folders.


_10
curl -X 'GET' \
_10
'$LANGFLOW_URL/api/v1/folders/' \
_10
-H 'accept: application/json'

Create folder

Create a new folder.


_10
curl -X 'POST' \
_10
"$LANGFLOW_URL/api/v1/folders/" \
_10
-H 'accept: application/json' \
_10
-H 'Content-Type: application/json' \
_10
-d '{
_10
"name": "new_folder_name",
_10
"description": "string",
_10
"components_list": [],
_10
"flows_list": []
_10
}'

To add flows and components at folder creation, retrieve the components_list and flows_list values from the /api/v1/store/components and /api/v1/flows/read endpoints and add them to the request body.

Adding a flow to a folder moves the flow from its previous location. The flow is not copied.


_14
curl -X 'POST' \
_14
"$LANGFLOW_URL/api/v1/folders/" \
_14
-H 'accept: application/json' \
_14
-H 'Content-Type: application/json' \
_14
-d '{
_14
"name": "new_folder_name",
_14
"description": "string",
_14
"components_list": [
_14
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
_14
],
_14
"flows_list": [
_14
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
_14
]
_14
}'

Read folder

Retrieve details of a specific folder.

To find the UUID of your folder, call the read folders endpoint.


_10
curl -X 'GET' \
_10
'$LANGFLOW_URL/api/v1/folders/$FOLDER_ID' \
_10
-H 'accept: application/json'

Update folder

Update the information of a specific folder with a PATCH request.

Each PATCH request updates the folder with the values you send. Only the fields you include in your request are updated. If you send the same values multiple times, the update is still processed, even if the values are unchanged.


_15
curl -X 'PATCH' \
_15
'$LANGFLOW_URL/api/v1/folders/b408ddb9-6266-4431-9be8-e04a62758331' \
_15
-H 'accept: application/json' \
_15
-H 'Content-Type: application/json' \
_15
-d '{
_15
"name": "string",
_15
"description": "string",
_15
"parent_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
_15
"components": [
_15
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
_15
],
_15
"flows": [
_15
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
_15
]
_15
}'

Delete folder

Delete a specific folder.


_10
curl -X 'DELETE' \
_10
'$LANGFLOW_URL/api/v1/folders/$FOLDER_ID' \
_10
-H 'accept: */*'

Download folder

Download all flows from a folder as a zip file.

The --output flag is optional.


_10
curl -X 'GET' \
_10
'$LANGFLOW_URL/api/v1/folders/download/b408ddb9-6266-4431-9be8-e04a62758331' \
_10
-H 'accept: application/json' \
_10
--output langflow-folder.zip

Upload folder

Upload a folder to Langflow.


_10
curl -X 'POST' \
_10
'$LANGFLOW_URL/api/v1/folders/upload/' \
_10
-H 'accept: application/json' \
_10
-H 'Content-Type: multipart/form-data' \
_10
-F 'file=@20241230_135006_langflow_flows.zip;type=application/zip'

Files

Use the /files endpoint to add or delete files between your local machine and Langflow.

Upload file

Upload a file to an existing flow.

This example uploads the_oscar_award.csv.


_10
curl -X 'POST' \
_10
'$LANGFLOW_URL/api/v1/files/upload/$FLOW_ID' \
_10
-H 'accept: application/json' \
_10
-H 'Content-Type: multipart/form-data' \
_10
-F 'file=@the_oscar_award.csv'

Upload image files

Send image files to the Langflow API for AI analysis.

The default file limit is 100 MB. To configure this value, change the LANGFLOW_MAX_FILE_SIZE_UPLOAD environment variable. For more information, see Supported environment variables.

  1. To send an image to your flow with the API, POST the image file to the v1/files/upload/<YOUR-FLOW-ID> endpoint of your flow.

_10
curl -X POST "$LANGFLOW_URL/api/v1/files/upload/a430cc57-06bb-4c11-be39-d3d4de68d2c4" \
_10
-H "Content-Type: multipart/form-data" \
_10
-F "file=@image-file.png"

The API returns the image file path in the format "file_path":"<YOUR-FLOW-ID>/<TIMESTAMP>_<FILE-NAME>"}.


_10
{"flowId":"a430cc57-06bb-4c11-be39-d3d4de68d2c4","file_path":"a430cc57-06bb-4c11-be39-d3d4de68d2c4/2024-11-27_14-47-50_image-file.png"}

  1. Post the image file to the Chat Input component of a Basic prompting flow. Pass the file path value as an input in the Tweaks section of the curl call to Langflow.

_12
curl -X POST \
_12
"$LANGFLOW_URL/api/v1/run/a430cc57-06bb-4c11-be39-d3d4de68d2c4?stream=false" \
_12
-H 'Content-Type: application/json'\
_12
-d '{
_12
"output_type": "chat",
_12
"input_type": "chat",
_12
"tweaks": {
_12
"ChatInput-b67sL": {
_12
"files": "a430cc57-06bb-4c11-be39-d3d4de68d2c4/2024-11-27_14-47-50_image-file.png",
_12
"input_value": "what do you see?"
_12
}
_12
}}'

Your chatbot describes the image file you sent.


_10
"text": "This flowchart appears to represent a complex system for processing financial inquiries using various AI agents and tools. Here's a breakdown of its components and how they might work together..."

List files

List all files associated with a specific flow.


_10
curl -X 'GET' \
_10
"$LANGFLOW_URL/api/v1/files/list/$FLOW_ID" \
_10
-H 'accept: application/json'

Download file

Download a specific file for a given flow.

To look up the file name in Langflow, use the /list endpoint.

This example downloads the 2024-12-30_15-19-43_the_oscar_award.csv file from Langflow to a file named output-file.csv.

The --output flag is optional.


_10
curl -X 'GET' \
_10
"$LANGFLOW_URL/api/v1/files/download/$FLOW_ID/2024-12-30_15-19-43_the_oscar_award.csv" \
_10
-H 'accept: application/json' \
_10
--output output-file.csv

Download image

Download an image file for a given flow.

To look up the file name in Langflow, use the /list endpoint.

This example downloads the 2024-12-30_15-42-44_image-file.png file from Langflow to a file named output-image.png.

The --output flag is optional.


_10
curl -X 'GET' \
_10
"$LANGFLOW_URL/api/v1/files/images/$FLOW_ID/2024-12-30_15-42-44_image-file.png" \
_10
-H 'accept: application/json' \
_10
--output output-image.png

Delete file

Delete a specific file from a flow.

This example deletes the 2024-12-30_15-42-44_image-file.png file from Langflow.


_10
curl -X 'DELETE' \
_10
"$LANGFLOW_URL/api/v1/files/delete/$FLOW_ID/2024-12-30_15-42-44_image-file.png" \
_10
-H 'accept: application/json'

Logs

Retrieve logs for your Langflow flow.

This endpoint requires log retrieval to be enabled in your Langflow application.

To enable log retrieval, include these values in your .env file:


_10
LANGFLOW_ENABLE_LOG_RETRIEVAL=true
_10
LANGFLOW_LOG_RETRIEVER_BUFFER_SIZE=10000
_10
LANGFLOW_LOG_LEVEL=DEBUG

For log retrieval to function, LANGFLOW_LOG_RETRIEVER_BUFFER_SIZE needs to be greater than 0. The default value is 10000.

Start Langflow with this .env:


_10
uv run langflow run --env-file .env

Stream logs

Stream logs in real-time using Server-Sent Events (SSE).


_10
curl -X 'GET' \
_10
"$LANGFLOW_URL/logs-stream" \
_10
-H 'accept: text/event-stream'

Retrieve logs with optional parameters

Retrieve logs with optional query parameters.

  • lines_before: The number of logs before the timestamp or the last log.
  • lines_after: The number of logs after the timestamp.
  • timestamp: The timestamp to start getting logs from.

The default values for all three parameters is 0. With these values, the endpoint returns the last 10 lines of logs.


_10
curl -X 'GET' \
_10
"$LANGFLOW_URL/logs?lines_before=0&lines_after=0&timestamp=0" \
_10
-H 'accept: application/json'

Base

Use the base Langflow API for running your flow and retrieving configuration information.

Get all components

This operation returns a dictionary of all Langflow components.


_10
curl -X 'GET' \
_10
"$LANGFLOW_URL/api/v1/all" \
_10
-H 'accept: application/json'

Run flow

Execute a specified flow by ID or name.


_20
curl -X 'POST' \
_20
"$LANGFLOW_URL/api/v1/run/$FLOW_ID?stream=false" \
_20
-H 'accept: application/json' \
_20
-H 'Content-Type: application/json' \
_20
-d '{
_20
"input_value": "string",
_20
"input_type": "chat",
_20
"output_type": "chat",
_20
"output_component": "",
_20
"tweaks": {
_20
"Component Name": {
_20
"parameter_name": "value"
_20
},
_20
"component_id": {
_20
"parameter_name": "value"
_20
},
_20
"parameter_name": "value"
_20
},
_20
"session_id": "string"
_20
}'

Webhook run flow

The webhook endpoint triggers flow execution with an HTTP POST request.


_10
curl -X POST \
_10
"$LANGFLOW_URL/api/v1/webhook/$FLOW_ID" \
_10
-H "Content-Type: application/json" \
_10
-d '{"path": "/tmp/test_file.txt"}'

Process

info

This endpoint is deprecated. Use the /run endpoint instead.

Predict

info

This endpoint is deprecated. Use the /run endpoint instead.

Get task status

Get the status of a task.


_10
curl -X 'GET' \
_10
"$LANGFLOW_URL/api/v1/task/TASK_ID" \
_10
-H 'accept: application/json'

Create upload file (Deprecated)

info

This endpoint is deprecated. Use the /file endpoint instead.

Get version

Get the version of the Langflow API.


_10
curl -X 'GET' \
_10
"$LANGFLOW_URL/api/v1/version" \
_10
-H 'accept: application/json'

Get config

Retrieve the Langflow configuration information.


_10
curl -X 'GET' \
_10
"$LANGFLOW_URL/api/v1/config" \
_10
-H 'accept: application/json'

Hi, how can I help you?