Use the /files endpoints to move files between your local machine and Langflow.
All /files endpoints (both /v1/files and /v2/files) require authentication with a Langflow API key.
You can only access files that belong to your own user account, even as a superuser.
Differences between /v1/files and /v2/files
There are two versions of the /files endpoints.
/v2/files offers the following improvements over /v1/files:
/v2 files are organized by user_id instead of flow_id.
This means files are owned by users, and they aren't attached to specific flows.
You can upload a file to Langflow one time, and use it with multiple flows.
/v2 files are tracked in the Langflow database.
/v2 supports bulk upload and delete.
/v2 responses contain more descriptive metadata.
However, /v2/files doesn't support image files.
To send image files to your flows through the API, use Upload image files (v1) .
Files/V1 endpoints
Use the /files endpoints to move files between your local machine and Langflow.
Upload file (v1)
Upload a file to the v1/files/upload/$FLOW_ID endpoint:
Replace FILE_NAME with the uploaded file name.
1 import os
2
3 import requests
4
5 url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/files/upload/{os.getenv('FLOW_ID', '')}"
6
7 headers = {
8 "accept": "application/json",
9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
10 }
11
12 files = {
13 "file": open(os.getenv("SAMPLE_UPLOAD_FILE", "docs/docs/API-Reference/fixtures/sample-upload.txt"), "rb"),
14 }
15
16 response = requests.request("POST", url, headers=headers, files=files)
17 response.raise_for_status()
18
19 print(response.text)
20
21 for _f in files.values():
22 if hasattr(_f, "close"):
23 _f.close()
24
1 const fs = require("fs");
2 const path = require("path");
3
4 const fixturesDir = path.join(__dirname, "../../fixtures");
5 const defaultUpload = path.join(fixturesDir, "sample-upload.txt");
6 const uploadPath = process.env.SAMPLE_UPLOAD_FILE || defaultUpload;
7 const uploadBuf = fs.readFileSync(uploadPath);
8 const uploadName = path.basename(uploadPath);
9
10 const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/files/upload/${process.env.FLOW_ID ?? ""}`;
11
12 const formData = new FormData();
13 formData.append("file", new Blob([uploadBuf]), uploadName);
14
15 const options = {
16 method: "POST",
17 headers: {
18 accept: "application/json",
19 "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
20 },
21 body: formData,
22 };
23
24 fetch(url, options)
25 .then(async (response) => {
26 if (!response.ok) {
27 throw new Error(`HTTP ${response.status}`);
28 }
29 const text = await response.text();
30 console.log(text);
31 })
32 .catch((error) => console.error(error));
33
1 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2 DEFAULT_UPLOAD_FILE="$SCRIPT_DIR/../../fixtures/sample-upload.txt"
3 UPLOAD_FILE="${SAMPLE_UPLOAD_FILE:-$DEFAULT_UPLOAD_FILE}"
4
5 curl -X POST \
6 "$LANGFLOW_URL/api/v1/files/upload/$FLOW_ID" \
7 -H "accept: application/json" \
8 -H "Content-Type: multipart/form-data" \
9 -H "x-api-key: $LANGFLOW_API_KEY" \
10 -F "file=@${UPLOAD_FILE}"
11
Replace FILE_NAME.txt with the name and extension of the file you want to upload.
Not all file types are supported.
Result 1 {
2 "flowId": "92f9a4c5-cfc8-4656-ae63-1f0881163c28",
3 "file_path": "92f9a4c5-cfc8-4656-ae63-1f0881163c28/2024-12-30_15-19-43_your_file.txt"
4 }
5
Upload image files (v1)
Send image files to Langflow to use them in flows.
The default file limit is 1024 MB.
To change this limit, set the LANGFLOW_MAX_FILE_SIZE_UPLOAD environment variable .
Attach the image to a POST /v1/files/upload/$FLOW_ID request with --form (-F) and the file path:
1 import os
2
3 import requests
4
5 url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/files/upload/{os.getenv('FLOW_ID', '')}"
6
7 headers = {
8 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
9 }
10
11 files = {
12 "file": open(os.getenv("SAMPLE_IMAGE_FILE", "docs/docs/API-Reference/fixtures/sample-upload.png"), "rb"),
13 }
14
15 response = requests.request("POST", url, headers=headers, files=files)
16 response.raise_for_status()
17
18 print(response.text)
19
20 for _f in files.values():
21 if hasattr(_f, "close"):
22 _f.close()
23
1 const fs = require("fs");
2 const path = require("path");
3
4 const fixturesDir = path.join(__dirname, "../../fixtures");
5 const defaultImage = path.join(fixturesDir, "sample-upload.png");
6 const imagePath = process.env.SAMPLE_IMAGE_FILE || defaultImage;
7 const imageBuf = fs.readFileSync(imagePath);
8 const imageName = path.basename(imagePath);
9
10 const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/files/upload/${process.env.FLOW_ID ?? ""}`;
11
12 const formData = new FormData();
13 formData.append("file", new Blob([imageBuf]), imageName);
14
15 const options = {
16 method: "POST",
17 headers: {
18 "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
19 },
20 body: formData,
21 };
22
23 fetch(url, options)
24 .then(async (response) => {
25 if (!response.ok) {
26 throw new Error(`HTTP ${response.status}`);
27 }
28 const text = await response.text();
29 console.log(text);
30 })
31 .catch((error) => console.error(error));
32
1 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2 DEFAULT_IMAGE_FILE="$SCRIPT_DIR/../../fixtures/sample-upload.png"
3 IMAGE_FILE="${SAMPLE_IMAGE_FILE:-$DEFAULT_IMAGE_FILE}"
4
5 curl -X POST "$LANGFLOW_URL/api/v1/files/upload/$FLOW_ID" \
6 -H "Content-Type: multipart/form-data" \
7 -H "x-api-key: $LANGFLOW_API_KEY" \
8 -F "file=@${IMAGE_FILE}"
9
A successful request returns the file_path for the image in the Langflow file management system in the format FLOW_ID/TIMESTAMP_FILENAME.TYPE.
For example:
_10 "flowId": "a430cc57-06bb-4c11-be39-d3d4de68d2c4",
_10 "file_path": "a430cc57-06bb-4c11-be39-d3d4de68d2c4/2024-11-27_14-47-50_image-file.png"
Use the returned file_path to send the image file to other components that can accept file input. Where you specify the file path depends on the component type.
The following example runs the Basic Prompting template flow, passing the image file and the query describe this image as input for the Chat Input component.
In this case, the file path is specified in tweaks.
1 import json
2 import os
3 from pathlib import Path
4
5 import requests
6
7 base = os.environ.get("LANGFLOW_URL", "")
8 flow_id = os.environ.get("FLOW_ID", "")
9 api_key = os.environ.get("LANGFLOW_API_KEY", "")
10
11 fixtures = Path(__file__).resolve().parents[2] / "fixtures"
12 image_path = Path(os.environ.get("SAMPLE_IMAGE_FILE", str(fixtures / "sample-upload.png")))
13
14 headers = {"accept": "application/json", "x-api-key": api_key}
15
16 upload = requests.post(
17 f"{base}/api/v1/files/upload/{flow_id}",
18 headers=headers,
19 files={"file": (image_path.name, image_path.read_bytes(), "image/png")},
20 timeout=30,
21 )
22 upload.raise_for_status()
23
24 listed = requests.get(f"{base}/api/v1/files/list/{flow_id}", headers=headers, timeout=30)
25 listed.raise_for_status()
26 print(json.dumps({"upload": upload.json(), "list": listed.json()}))
27
1 const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/run/a430cc57-06bb-4c11-be39-d3d4de68d2c4?stream=false`;
2
3 const options = {
4 method: 'POST',
5 headers: {
6 "Content-Type": `application/json`,
7 "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
8 },
9 body: JSON.stringify({
10 "output_type": "chat",
11 "input_type": "chat",
12 "tweaks": {
13 "ChatInput-b67sL": {
14 "files": "a430cc57-06bb-4c11-be39-d3d4de68d2c4/2024-11-27_14-47-50_image-file.png",
15 "input_value": "describe this image"
16 }
17 }
18 }),
19 };
20
21 fetch(url, options)
22 .then(async (response) => {
23 if (!response.ok) {
24 throw new Error(`HTTP ${response.status}`);
25 }
26 const text = await response.text();
27 console.log(text);
28 })
29 .catch((error) => console.error(error));
30
1 curl -X POST \
2 "$LANGFLOW_URL/api/v1/run/a430cc57-06bb-4c11-be39-d3d4de68d2c4?stream=false" \
3 -H "Content-Type: application/json" \
4 -H "x-api-key: $LANGFLOW_API_KEY" \
5 -d '{
6 "output_type": "chat",
7 "input_type": "chat",
8 "tweaks": {
9 "ChatInput-b67sL": {
10 "files": "a430cc57-06bb-4c11-be39-d3d4de68d2c4/2024-11-27_14-47-50_image-file.png",
11 "input_value": "describe this image"
12 }
13 }
14 }'
15
For help with tweaks, use the Input Schema in a flow's API access pane .
Setting tweaks with Input Schema also automatically populates the required component IDs.
List files (v1)
List all files associated with a specific flow.
1 import os
2
3 import requests
4
5 url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/files/list/{os.getenv('FLOW_ID', '')}"
6
7 headers = {
8 "accept": "application/json",
9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
10 }
11
12 response = requests.request("GET", url, headers=headers)
13 response.raise_for_status()
14
15 print(response.text)
16
1 const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/files/list/${process.env.FLOW_ID ?? ""}`;
2
3 const options = {
4 method: 'GET',
5 headers: {
6 "accept": `application/json`,
7 "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
8 },
9 };
10
11 fetch(url, options)
12 .then(async (response) => {
13 if (!response.ok) {
14 throw new Error(`HTTP ${response.status}`);
15 }
16 const text = await response.text();
17 console.log(text);
18 })
19 .catch((error) => console.error(error));
20
1 curl -X GET \
2 "$LANGFLOW_URL/api/v1/files/list/$FLOW_ID" \
3 -H "accept: application/json" \
4 -H "x-api-key: $LANGFLOW_API_KEY"
5
Result 1 {
2 "files": ["2024-12-30_15-19-43_your_file.txt"]
3 }
4
Download file (v1)
Download a specific file from a flow.
1 import json
2 import os
3 from pathlib import Path
4
5 import requests
6
7 base = os.environ.get("LANGFLOW_URL", "")
8 flow_id = os.environ.get("FLOW_ID", "")
9 api_key = os.environ.get("LANGFLOW_API_KEY", "")
10
11 fixtures = Path(__file__).resolve().parents[2] / "fixtures"
12 upload_path = Path(os.environ.get("SAMPLE_UPLOAD_FILE", str(fixtures / "sample-upload.txt")))
13
14 headers = {"accept": "application/json", "x-api-key": api_key}
15
16 upload = requests.post(
17 f"{base}/api/v1/files/upload/{flow_id}",
18 headers=headers,
19 files={"file": (upload_path.name, upload_path.read_bytes(), "text/plain")},
20 timeout=30,
21 )
22 upload.raise_for_status()
23 meta = upload.json()
24 file_name = meta["file_path"].split("/")[-1]
25
26 download = requests.get(
27 f"{base}/api/v1/files/download/{flow_id}/{file_name}",
28 headers=headers,
29 timeout=30,
30 )
31 download.raise_for_status()
32
33 out_path = Path("downloaded_file.txt")
34 out_path.write_bytes(download.content)
35 print(json.dumps({"saved_bytes": len(download.content), "path": str(out_path), "upload": meta}))
36
1 const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/files/download/${process.env.FLOW_ID ?? ""}/2024-12-30_15-19-43_your_file.txt`;
2
3 const options = {
4 method: 'GET',
5 headers: {
6 "accept": `application/json`,
7 "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
8 },
9 };
10
11 fetch(url, options)
12 .then(async (response) => {
13 if (!response.ok) {
14 throw new Error(`HTTP ${response.status}`);
15 }
16 const data = await response.arrayBuffer();
17 console.log("Received binary response for downloaded_file.txt", data.byteLength);
18 })
19 .catch((error) => console.error(error));
20
1 curl -X GET \
2 "$LANGFLOW_URL/api/v1/files/download/$FLOW_ID/2024-12-30_15-19-43_your_file.txt" \
3 -H "accept: application/json" \
4 -H "x-api-key: $LANGFLOW_API_KEY" \
5 --output downloaded_file.txt
6
Result 1 File contents downloaded to downloaded_file.txt
2
Delete file (v1)
Delete a specific file from a flow.
1 import os
2
3 import requests
4
5 url = (
6 f"{os.getenv('LANGFLOW_URL', '')}/api/v1/files/delete/{os.getenv('FLOW_ID', '')}/2024-12-30_15-19-43_your_file.txt"
7 )
8
9 headers = {
10 "accept": "application/json",
11 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
12 }
13
14 response = requests.request("DELETE", url, headers=headers)
15 response.raise_for_status()
16
17 print(response.text)
18
1 const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/files/delete/${process.env.FLOW_ID ?? ""}/2024-12-30_15-19-43_your_file.txt`;
2
3 const options = {
4 method: 'DELETE',
5 headers: {
6 "accept": `application/json`,
7 "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
8 },
9 };
10
11 fetch(url, options)
12 .then(async (response) => {
13 if (!response.ok) {
14 throw new Error(`HTTP ${response.status}`);
15 }
16 const text = await response.text();
17 console.log(text);
18 })
19 .catch((error) => console.error(error));
20
1 curl -X DELETE \
2 "$LANGFLOW_URL/api/v1/files/delete/$FLOW_ID/2024-12-30_15-19-43_your_file.txt" \
3 -H "accept: application/json" \
4 -H "x-api-key: $LANGFLOW_API_KEY"
5
Result 1 {
2 "message": "File 2024-12-30_15-19-43_your_file.txt deleted successfully"
3 }
4
Files/V2 endpoints
Use the /files endpoints to move files between your local machine and Langflow.
The /v2/files endpoints can be authenticated by an API key or JWT.
To create a Langflow API key and export it as an environment variable, see Get started with the Langflow API .
Upload file (v2)
Upload a file to your user account. The file can be used across multiple flows.
The file is uploaded in the format USER_ID/FILE_ID.FILE_EXTENSION, such as 07e5b864-e367-4f52-b647-a48035ae7e5e/d44dc2e1-9ae9-4cf6-9114-8d34a6126c94.pdf.
To retrieve your current user_id, call the /whoami endpoint:
1 import os
2
3 import requests
4
5 url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/users/whoami"
6
7 headers = {
8 "accept": "application/json",
9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
10 }
11
12 response = requests.request("GET", url, headers=headers)
13 response.raise_for_status()
14
15 print(response.text)
16
1 const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/users/whoami`;
2
3 const options = {
4 method: 'GET',
5 headers: {
6 "accept": `application/json`,
7 "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
8 },
9 };
10
11 fetch(url, options)
12 .then(async (response) => {
13 if (!response.ok) {
14 throw new Error(`HTTP ${response.status}`);
15 }
16 const text = await response.text();
17 console.log(text);
18 })
19 .catch((error) => console.error(error));
20
1 curl -X GET \
2 "$LANGFLOW_URL/api/v1/users/whoami" \
3 -H "accept: application/json" \
4 -H "x-api-key: $LANGFLOW_API_KEY"
5
Result 1 {"id":"07e5b864-e367-4f52-b647-a48035ae7e5e","username":"langflow","profile_image":null,"store_api_key":null,"is_active":true,"is_superuser":true,"create_at":"2025-05-08T17:59:07.855965","updated_at":"2025-05-28T19:00:42.556460","last_login_at":"2025-05-28T19:00:42.554338","optins":{"github_starred":false,"dialog_dismissed":true,"discord_clicked":false,"mcp_dialog_dismissed":true}}
2
In the POST request to v2/files, replace @FILE_NAME.EXTENSION with the uploaded file name and its extension.
You must include the ampersand (@) in the request to instruct curl to upload the contents of the file, not the string FILE_NAME.EXTENSION.
1 import os
2
3 import requests
4
5 url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files"
6
7 headers = {
8 "accept": "application/json",
9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
10 }
11
12 files = {
13 "file": open(os.getenv("SAMPLE_UPLOAD_FILE", "docs/docs/API-Reference/fixtures/sample-upload.txt"), "rb"),
14 }
15
16 response = requests.request("POST", url, headers=headers, files=files)
17 response.raise_for_status()
18
19 print(response.text)
20
21 for _f in files.values():
22 if hasattr(_f, "close"):
23 _f.close()
24
1 const fs = require("fs");
2 const path = require("path");
3
4 const fixturesDir = path.join(__dirname, "../../fixtures");
5 const defaultUpload = path.join(fixturesDir, "sample-upload.txt");
6 const uploadPath = process.env.SAMPLE_UPLOAD_FILE || defaultUpload;
7 const uploadBuf = fs.readFileSync(uploadPath);
8 const uploadName = path.basename(uploadPath);
9
10 const url = `${process.env.LANGFLOW_URL ?? ""}/api/v2/files`;
11
12 const formData = new FormData();
13 formData.append("file", new Blob([uploadBuf]), uploadName);
14
15 const options = {
16 method: "POST",
17 headers: {
18 accept: "application/json",
19 "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
20 },
21 body: formData,
22 };
23
24 fetch(url, options)
25 .then(async (response) => {
26 if (!response.ok) {
27 throw new Error(`HTTP ${response.status}`);
28 }
29 const text = await response.text();
30 console.log(text);
31 })
32 .catch((error) => console.error(error));
33
1 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2 DEFAULT_UPLOAD_FILE="$SCRIPT_DIR/../../fixtures/sample-upload.txt"
3 UPLOAD_FILE="${SAMPLE_UPLOAD_FILE:-$DEFAULT_UPLOAD_FILE}"
4
5 curl -X POST \
6 "$LANGFLOW_URL/api/v2/files" \
7 -H "accept: application/json" \
8 -H "Content-Type: multipart/form-data" \
9 -H "x-api-key: $LANGFLOW_API_KEY" \
10 -F "file=@${UPLOAD_FILE}"
11
The file is uploaded in the format USER_ID/FILE_ID.FILE_EXTENSION, and the API returns metadata about the uploaded file:
_10 "id":"d44dc2e1-9ae9-4cf6-9114-8d34a6126c94",
_10 "name":"engine_manual",
_10 "path":"07e5b864-e367-4f52-b647-a48035ae7e5e/d44dc2e1-9ae9-4cf6-9114-8d34a6126c94.pdf",
Send files to your flows (v2)
The /v2/files endpoint can't send image files to flows.
To send image files to your flows through the API, see Upload image files (v1) .
This endpoint uploads files to your Langflow server's file management system.
To use an uploaded file in a flow, send the file path to a flow with a Read File component .
The default file limit is 1024 MB. To configure this value, change the LANGFLOW_MAX_FILE_SIZE_UPLOAD environment variable .
To send a file to your flow with the API, POST the file to the /api/v2/files endpoint.
Replace FILE_NAME.EXTENSION with the name and extension of the file you want to upload.
This is the same step described in Upload file (v2) , but since you need the filename to upload to your flow, it is included here.
1 import os
2
3 import requests
4
5 url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files"
6
7 headers = {
8 "accept": "application/json",
9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
10 }
11
12 files = {
13 "file": open(os.getenv("SAMPLE_UPLOAD_FILE", "docs/docs/API-Reference/fixtures/sample-upload.txt"), "rb"),
14 }
15
16 response = requests.request("POST", url, headers=headers, files=files)
17 response.raise_for_status()
18
19 print(response.text)
20
21 for _f in files.values():
22 if hasattr(_f, "close"):
23 _f.close()
24
1 const fs = require("fs");
2 const path = require("path");
3
4 const fixturesDir = path.join(__dirname, "../../fixtures");
5 const defaultUpload = path.join(fixturesDir, "sample-upload.txt");
6 const uploadPath = process.env.SAMPLE_UPLOAD_FILE || defaultUpload;
7 const uploadBuf = fs.readFileSync(uploadPath);
8 const uploadName = path.basename(uploadPath);
9
10 const url = `${process.env.LANGFLOW_URL ?? ""}/api/v2/files`;
11
12 const formData = new FormData();
13 formData.append("file", new Blob([uploadBuf]), uploadName);
14
15 const options = {
16 method: "POST",
17 headers: {
18 accept: "application/json",
19 "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
20 },
21 body: formData,
22 };
23
24 fetch(url, options)
25 .then(async (response) => {
26 if (!response.ok) {
27 throw new Error(`HTTP ${response.status}`);
28 }
29 const text = await response.text();
30 console.log(text);
31 })
32 .catch((error) => console.error(error));
33
1 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2 DEFAULT_UPLOAD_FILE="$SCRIPT_DIR/../../fixtures/sample-upload.txt"
3 UPLOAD_FILE="${SAMPLE_UPLOAD_FILE:-$DEFAULT_UPLOAD_FILE}"
4
5 curl -X POST \
6 "$LANGFLOW_URL/api/v2/files" \
7 -H "accept: application/json" \
8 -H "Content-Type: multipart/form-data" \
9 -H "x-api-key: $LANGFLOW_API_KEY" \
10 -F "file=@${UPLOAD_FILE}"
11
The file is uploaded in the format USER_ID/FILE_ID.FILE_EXTENSION, and the API returns metadata about the uploaded file:
_10 "id":"d44dc2e1-9ae9-4cf6-9114-8d34a6126c94",
_10 "name":"engine_manual",
_10 "path":"07e5b864-e367-4f52-b647-a48035ae7e5e/d44dc2e1-9ae9-4cf6-9114-8d34a6126c94.pdf",
To use this file in your flow, add a Read File component to your flow.
This component loads files into flows from your local machine or Langflow file management.
Run the flow, passing the path to the Read-File component in the tweaks object:
1 import os
2
3 import requests
4
5 url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/run/{os.getenv('FLOW_ID', '')}"
6
7 headers = {
8 "Content-Type": "application/json",
9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
10 }
11
12 payload = {
13 "input_value": "what do you see?",
14 "output_type": "chat",
15 "input_type": "text",
16 "tweaks": {
17 "Read-File-1olS3": {"path": ["07e5b864-e367-4f52-b647-a48035ae7e5e/3a290013-fe1e-4d3d-a454-cacae81288f3.pdf"]}
18 },
19 }
20
21 response = requests.request("POST", url, headers=headers, json=payload)
22 response.raise_for_status()
23
24 print(response.text)
25
1 const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/run/${process.env.FLOW_ID ?? ""}`;
2
3 const options = {
4 method: 'POST',
5 headers: {
6 "Content-Type": `application/json`,
7 "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
8 },
9 body: JSON.stringify({
10 "input_value": "what do you see?",
11 "output_type": "chat",
12 "input_type": "text",
13 "tweaks": {
14 "Read-File-1olS3": {
15 "path": [
16 "07e5b864-e367-4f52-b647-a48035ae7e5e/3a290013-fe1e-4d3d-a454-cacae81288f3.pdf"
17 ]
18 }
19 }
20 }),
21 };
22
23 fetch(url, options)
24 .then(async (response) => {
25 if (!response.ok) {
26 throw new Error(`HTTP ${response.status}`);
27 }
28 const text = await response.text();
29 console.log(text);
30 })
31 .catch((error) => console.error(error));
32
1 curl --request POST \
2 --url "$LANGFLOW_URL/api/v1/run/$FLOW_ID" \
3 --header "Content-Type: application/json" \
4 --header "x-api-key: $LANGFLOW_API_KEY" \
5 --data '{
6 "input_value": "what do you see?",
7 "output_type": "chat",
8 "input_type": "text",
9 "tweaks": {
10 "Read-File-1olS3": {
11 "path": [
12 "07e5b864-e367-4f52-b647-a48035ae7e5e/3a290013-fe1e-4d3d-a454-cacae81288f3.pdf"
13 ]
14 }
15 }
16 }'
17
To get the Read-File component's ID, call the Read flow endpoint or inspect the component in the visual editor.
If the file path is valid, the flow runs successfully.
List files (v2)
List all files associated with your user account.
1 import os
2
3 import requests
4
5 url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files"
6
7 headers = {
8 "accept": "application/json",
9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
10 }
11
12 response = requests.request("GET", url, headers=headers)
13 response.raise_for_status()
14
15 print(response.text)
16
1 const url = `${process.env.LANGFLOW_URL ?? ""}/api/v2/files`;
2
3 const options = {
4 method: 'GET',
5 headers: {
6 "accept": `application/json`,
7 "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
8 },
9 };
10
11 fetch(url, options)
12 .then(async (response) => {
13 if (!response.ok) {
14 throw new Error(`HTTP ${response.status}`);
15 }
16 const text = await response.text();
17 console.log(text);
18 })
19 .catch((error) => console.error(error));
20
1 curl -X GET \
2 "$LANGFLOW_URL/api/v2/files" \
3 -H "accept: application/json" \
4 -H "x-api-key: $LANGFLOW_API_KEY"
5
Result 1 [
2 {
3 "id": "c7b22c4c-d5e0-4ec9-af97-5d85b7657a34",
4 "name": "your_file",
5 "path": "6f17a73e-97d7-4519-a8d9-8e4c0be411bb/c7b22c4c-d5e0-4ec9-af97-5d85b7657a34.txt",
6 "size": 1234,
7 "provider": null
8 }
9 ]
10
Download file (v2)
Download a specific file by its ID and file extension.
You must specify the file type you expect in the --output value.
1 import json
2 import os
3 from pathlib import Path
4
5 import requests
6
7 base = os.environ.get("LANGFLOW_URL", "")
8 api_key = os.environ.get("LANGFLOW_API_KEY", "")
9
10 fixtures = Path(__file__).resolve().parents[2] / "fixtures"
11 upload_path = Path(os.environ.get("SAMPLE_UPLOAD_FILE", str(fixtures / "sample-upload.txt")))
12
13 headers = {"accept": "application/json", "x-api-key": api_key}
14
15 upload = requests.post(
16 f"{base}/api/v2/files",
17 headers=headers,
18 files={"file": (upload_path.name, upload_path.read_bytes(), "text/plain")},
19 timeout=30,
20 )
21 upload.raise_for_status()
22 file_id = upload.json()["id"]
23
24 download = requests.get(
25 f"{base}/api/v2/files/{file_id}",
26 headers=headers,
27 timeout=30,
28 )
29 download.raise_for_status()
30
31 out_path = Path("downloaded_file.txt")
32 out_path.write_bytes(download.content)
33 print(json.dumps({"saved_bytes": len(download.content), "file_id": str(file_id), "path": str(out_path)}))
34
1 const url = `${process.env.LANGFLOW_URL ?? ""}/api/v2/files/c7b22c4c-d5e0-4ec9-af97-5d85b7657a34`;
2
3 const options = {
4 method: 'GET',
5 headers: {
6 "accept": `application/json`,
7 "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
8 },
9 };
10
11 fetch(url, options)
12 .then(async (response) => {
13 if (!response.ok) {
14 throw new Error(`HTTP ${response.status}`);
15 }
16 const data = await response.arrayBuffer();
17 console.log("Received binary response for downloaded_file.txt", data.byteLength);
18 })
19 .catch((error) => console.error(error));
20
1 curl -X GET \
2 "$LANGFLOW_URL/api/v2/files/c7b22c4c-d5e0-4ec9-af97-5d85b7657a34" \
3 -H "accept: application/json" \
4 -H "x-api-key: $LANGFLOW_API_KEY" \
5 --output downloaded_file.txt
6
Result 1 File contents downloaded to downloaded_file.txt
2
Edit file name (v2)
Change a file name.
1 import json
2 import os
3 from pathlib import Path
4 from urllib.parse import quote
5
6 import requests
7
8 base = os.environ.get("LANGFLOW_URL", "")
9 api_key = os.environ.get("LANGFLOW_API_KEY", "")
10
11 fixtures = Path(__file__).resolve().parents[2] / "fixtures"
12 upload_path = Path(os.environ.get("SAMPLE_UPLOAD_FILE", str(fixtures / "sample-upload.txt")))
13
14 headers = {"accept": "application/json", "x-api-key": api_key}
15
16 upload = requests.post(
17 f"{base}/api/v2/files",
18 headers=headers,
19 files={"file": (upload_path.name, upload_path.read_bytes(), "text/plain")},
20 timeout=30,
21 )
22 upload.raise_for_status()
23 file_id = upload.json()["id"]
24
25 new_name = os.environ.get("RENAMED_FILE_BASENAME", "renamed-sample-upload")
26 url = f"{base}/api/v2/files/{file_id}?name={quote(new_name)}"
27
28 response = requests.put(url, headers=headers, timeout=30)
29 response.raise_for_status()
30 print(json.dumps(response.json()))
31
1 const url = `${process.env.LANGFLOW_URL ?? ""}/api/v2/files/${process.env.FILE_ID ?? ""}?name=new_file_name`;
2
3 const options = {
4 method: 'PUT',
5 headers: {
6 "accept": `application/json`,
7 "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
8 },
9 };
10
11 fetch(url, options)
12 .then(async (response) => {
13 if (!response.ok) {
14 throw new Error(`HTTP ${response.status}`);
15 }
16 const text = await response.text();
17 console.log(text);
18 })
19 .catch((error) => console.error(error));
20
1 curl -X PUT \
2 "$LANGFLOW_URL/api/v2/files/$FILE_ID?name=new_file_name" \
3 -H "accept: application/json" \
4 -H "x-api-key: $LANGFLOW_API_KEY"
5
Result 1 {
2 "id": "76543e40-f388-4cb3-b0ee-a1e870aca3d3",
3 "name": "new_file_name",
4 "path": "6f17a73e-97d7-4519-a8d9-8e4c0be411bb/76543e40-f388-4cb3-b0ee-a1e870aca3d3.png",
5 "size": 2728251,
6 "provider": null
7 }
8
Delete file (v2)
Delete a specific file by its ID.
1 import os
2
3 import requests
4
5 url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files/{os.getenv('FILE_ID', '')}"
6
7 headers = {
8 "accept": "application/json",
9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
10 }
11
12 response = requests.request("DELETE", url, headers=headers)
13 response.raise_for_status()
14
15 print(response.text)
16
1 const url = `${process.env.LANGFLOW_URL ?? ""}/api/v2/files/${process.env.FILE_ID ?? ""}`;
2
3 const options = {
4 method: 'DELETE',
5 headers: {
6 "accept": `application/json`,
7 "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
8 },
9 };
10
11 fetch(url, options)
12 .then(async (response) => {
13 if (!response.ok) {
14 throw new Error(`HTTP ${response.status}`);
15 }
16 const text = await response.text();
17 console.log(text);
18 })
19 .catch((error) => console.error(error));
20
1 curl -X DELETE \
2 "$LANGFLOW_URL/api/v2/files/$FILE_ID" \
3 -H "accept: application/json" \
4 -H "x-api-key: $LANGFLOW_API_KEY"
5
Result 1 {
2 "message": "File deleted successfully"
3 }
4
Delete all files (v2)
Delete all files associated with your user account.
1 import os
2
3 import requests
4
5 url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files"
6
7 headers = {
8 "accept": "application/json",
9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
10 }
11
12 response = requests.request("DELETE", url, headers=headers)
13 response.raise_for_status()
14
15 print(response.text)
16
1 const url = `${process.env.LANGFLOW_URL ?? ""}/api/v2/files`;
2
3 const options = {
4 method: 'DELETE',
5 headers: {
6 "accept": `application/json`,
7 "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
8 },
9 };
10
11 fetch(url, options)
12 .then(async (response) => {
13 if (!response.ok) {
14 throw new Error(`HTTP ${response.status}`);
15 }
16 const text = await response.text();
17 console.log(text);
18 })
19 .catch((error) => console.error(error));
20
1 curl -X DELETE \
2 "$LANGFLOW_URL/api/v2/files" \
3 -H "accept: application/json" \
4 -H "x-api-key: $LANGFLOW_API_KEY"
5
Result 1 {
2 "message": "All files deleted successfully"
3 }
4
Create upload file (Deprecated)
This endpoint is deprecated. Use the /files endpoints instead.
See also