Skip to main content
Version: 1.10.x (Next)

Files endpoints

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.

1import os 2 3import requests 4 5url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/files/upload/{os.getenv('FLOW_ID', '')}" 6 7headers = { 8 "accept": "application/json", 9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", 10} 11 12files = { 13 "file": open(os.getenv("SAMPLE_UPLOAD_FILE", "docs/docs/API-Reference/fixtures/sample-upload.txt"), "rb"), 14} 15 16response = requests.request("POST", url, headers=headers, files=files) 17response.raise_for_status() 18 19print(response.text) 20 21for _f in files.values(): 22 if hasattr(_f, "close"): 23 _f.close() 24

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.

  1. Attach the image to a POST /v1/files/upload/$FLOW_ID request with --form (-F) and the file path:

    1import os 2 3import requests 4 5url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/files/upload/{os.getenv('FLOW_ID', '')}" 6 7headers = { 8 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", 9} 10 11files = { 12 "file": open(os.getenv("SAMPLE_IMAGE_FILE", "docs/docs/API-Reference/fixtures/sample-upload.png"), "rb"), 13} 14 15response = requests.request("POST", url, headers=headers, files=files) 16response.raise_for_status() 17 18print(response.text) 19 20for _f in files.values(): 21 if hasattr(_f, "close"): 22 _f.close() 23

    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
    {
    _10
    "flowId": "a430cc57-06bb-4c11-be39-d3d4de68d2c4",
    _10
    "file_path": "a430cc57-06bb-4c11-be39-d3d4de68d2c4/2024-11-27_14-47-50_image-file.png"
    _10
    }

  2. 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.

    1import json 2import os 3from pathlib import Path 4 5import requests 6 7base = os.environ.get("LANGFLOW_URL", "") 8flow_id = os.environ.get("FLOW_ID", "") 9api_key = os.environ.get("LANGFLOW_API_KEY", "") 10 11fixtures = Path(__file__).resolve().parents[2] / "fixtures" 12image_path = Path(os.environ.get("SAMPLE_IMAGE_FILE", str(fixtures / "sample-upload.png"))) 13 14headers = {"accept": "application/json", "x-api-key": api_key} 15 16upload = 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) 22upload.raise_for_status() 23 24listed = requests.get(f"{base}/api/v1/files/list/{flow_id}", headers=headers, timeout=30) 25listed.raise_for_status() 26print(json.dumps({"upload": upload.json(), "list": listed.json()})) 27
    tip

    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.

1import os 2 3import requests 4 5url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/files/list/{os.getenv('FLOW_ID', '')}" 6 7headers = { 8 "accept": "application/json", 9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", 10} 11 12response = requests.request("GET", url, headers=headers) 13response.raise_for_status() 14 15print(response.text) 16
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.

1import json 2import os 3from pathlib import Path 4 5import requests 6 7base = os.environ.get("LANGFLOW_URL", "") 8flow_id = os.environ.get("FLOW_ID", "") 9api_key = os.environ.get("LANGFLOW_API_KEY", "") 10 11fixtures = Path(__file__).resolve().parents[2] / "fixtures" 12upload_path = Path(os.environ.get("SAMPLE_UPLOAD_FILE", str(fixtures / "sample-upload.txt"))) 13 14headers = {"accept": "application/json", "x-api-key": api_key} 15 16upload = 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) 22upload.raise_for_status() 23meta = upload.json() 24file_name = meta["file_path"].split("/")[-1] 25 26download = requests.get( 27 f"{base}/api/v1/files/download/{flow_id}/{file_name}", 28 headers=headers, 29 timeout=30, 30) 31download.raise_for_status() 32 33out_path = Path("downloaded_file.txt") 34out_path.write_bytes(download.content) 35print(json.dumps({"saved_bytes": len(download.content), "path": str(out_path), "upload": meta})) 36
Result
1File contents downloaded to downloaded_file.txt 2

Delete file (v1)

Delete a specific file from a flow.

1import os 2 3import requests 4 5url = ( 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 9headers = { 10 "accept": "application/json", 11 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", 12} 13 14response = requests.request("DELETE", url, headers=headers) 15response.raise_for_status() 16 17print(response.text) 18
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.

  1. To retrieve your current user_id, call the /whoami endpoint:

    1import os 2 3import requests 4 5url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/users/whoami" 6 7headers = { 8 "accept": "application/json", 9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", 10} 11 12response = requests.request("GET", url, headers=headers) 13response.raise_for_status() 14 15print(response.text) 16
    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
  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.

    1import os 2 3import requests 4 5url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files" 6 7headers = { 8 "accept": "application/json", 9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", 10} 11 12files = { 13 "file": open(os.getenv("SAMPLE_UPLOAD_FILE", "docs/docs/API-Reference/fixtures/sample-upload.txt"), "rb"), 14} 15 16response = requests.request("POST", url, headers=headers, files=files) 17response.raise_for_status() 18 19print(response.text) 20 21for _f in files.values(): 22 if hasattr(_f, "close"): 23 _f.close() 24

    The file is uploaded in the format USER_ID/FILE_ID.FILE_EXTENSION, and the API returns metadata about the uploaded file:


    _10
    {
    _10
    "id":"d44dc2e1-9ae9-4cf6-9114-8d34a6126c94",
    _10
    "name":"engine_manual",
    _10
    "path":"07e5b864-e367-4f52-b647-a48035ae7e5e/d44dc2e1-9ae9-4cf6-9114-8d34a6126c94.pdf",
    _10
    "size":851160,
    _10
    "provider":null
    _10
    }

Send files to your flows (v2)

info

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.

  1. 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.

    1import os 2 3import requests 4 5url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files" 6 7headers = { 8 "accept": "application/json", 9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", 10} 11 12files = { 13 "file": open(os.getenv("SAMPLE_UPLOAD_FILE", "docs/docs/API-Reference/fixtures/sample-upload.txt"), "rb"), 14} 15 16response = requests.request("POST", url, headers=headers, files=files) 17response.raise_for_status() 18 19print(response.text) 20 21for _f in files.values(): 22 if hasattr(_f, "close"): 23 _f.close() 24

    The file is uploaded in the format USER_ID/FILE_ID.FILE_EXTENSION, and the API returns metadata about the uploaded file:


    _10
    {
    _10
    "id":"d44dc2e1-9ae9-4cf6-9114-8d34a6126c94",
    _10
    "name":"engine_manual",
    _10
    "path":"07e5b864-e367-4f52-b647-a48035ae7e5e/d44dc2e1-9ae9-4cf6-9114-8d34a6126c94.pdf",
    _10
    "size":851160,
    _10
    "provider": null
    _10
    }

  2. 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.

  3. Run the flow, passing the path to the Read-File component in the tweaks object:

    1import os 2 3import requests 4 5url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/run/{os.getenv('FLOW_ID', '')}" 6 7headers = { 8 "Content-Type": "application/json", 9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", 10} 11 12payload = { 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 21response = requests.request("POST", url, headers=headers, json=payload) 22response.raise_for_status() 23 24print(response.text) 25

    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.

1import os 2 3import requests 4 5url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files" 6 7headers = { 8 "accept": "application/json", 9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", 10} 11 12response = requests.request("GET", url, headers=headers) 13response.raise_for_status() 14 15print(response.text) 16
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.

1import json 2import os 3from pathlib import Path 4 5import requests 6 7base = os.environ.get("LANGFLOW_URL", "") 8api_key = os.environ.get("LANGFLOW_API_KEY", "") 9 10fixtures = Path(__file__).resolve().parents[2] / "fixtures" 11upload_path = Path(os.environ.get("SAMPLE_UPLOAD_FILE", str(fixtures / "sample-upload.txt"))) 12 13headers = {"accept": "application/json", "x-api-key": api_key} 14 15upload = 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) 21upload.raise_for_status() 22file_id = upload.json()["id"] 23 24download = requests.get( 25 f"{base}/api/v2/files/{file_id}", 26 headers=headers, 27 timeout=30, 28) 29download.raise_for_status() 30 31out_path = Path("downloaded_file.txt") 32out_path.write_bytes(download.content) 33print(json.dumps({"saved_bytes": len(download.content), "file_id": str(file_id), "path": str(out_path)})) 34
Result
1File contents downloaded to downloaded_file.txt 2

Edit file name (v2)

Change a file name.

1import json 2import os 3from pathlib import Path 4from urllib.parse import quote 5 6import requests 7 8base = os.environ.get("LANGFLOW_URL", "") 9api_key = os.environ.get("LANGFLOW_API_KEY", "") 10 11fixtures = Path(__file__).resolve().parents[2] / "fixtures" 12upload_path = Path(os.environ.get("SAMPLE_UPLOAD_FILE", str(fixtures / "sample-upload.txt"))) 13 14headers = {"accept": "application/json", "x-api-key": api_key} 15 16upload = 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) 22upload.raise_for_status() 23file_id = upload.json()["id"] 24 25new_name = os.environ.get("RENAMED_FILE_BASENAME", "renamed-sample-upload") 26url = f"{base}/api/v2/files/{file_id}?name={quote(new_name)}" 27 28response = requests.put(url, headers=headers, timeout=30) 29response.raise_for_status() 30print(json.dumps(response.json())) 31
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.

1import os 2 3import requests 4 5url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files/{os.getenv('FILE_ID', '')}" 6 7headers = { 8 "accept": "application/json", 9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", 10} 11 12response = requests.request("DELETE", url, headers=headers) 13response.raise_for_status() 14 15print(response.text) 16
Result
1{ 2 "message": "File deleted successfully" 3} 4

Delete all files (v2)

Delete all files associated with your user account.

1import os 2 3import requests 4 5url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files" 6 7headers = { 8 "accept": "application/json", 9 "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", 10} 11 12response = requests.request("DELETE", url, headers=headers) 13response.raise_for_status() 14 15print(response.text) 16
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

Search