Skip to main content
Version: 1.12.x

Projects endpoints

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

Read projects​

Get a list of Langflow projects, including project IDs, names, and descriptions.

import os

import requests

url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/projects/"

headers = {
"accept": "application/json",
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
}

response = requests.request("GET", url, headers=headers)
response.raise_for_status()

print(response.text)
const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/`;

const options = {
method: 'GET',
headers: {
"accept": `application/json`,
"x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
},
};

fetch(url, options)
.then(async (response) => {
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const text = await response.text();
console.log(text);
})
.catch((error) => console.error(error));
curl -X GET \
"$LANGFLOW_URL/api/v1/projects/" \
-H "accept: application/json" \
-H "x-api-key: $LANGFLOW_API_KEY"
Result
[
{
"name": "Starter Project",
"description": "Manage your own projects. Download and upload projects.",
"id": "1415de42-8f01-4f36-bf34-539f23e47466",
"parent_id": null
}
]

Create project​

Create a new project.

import os

import requests

url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/projects/"

headers = {
"Content-Type": "application/json",
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
}

payload = {"name": "new_project_name", "description": "string", "components_list": [], "flows_list": []}

response = requests.request("POST", url, headers=headers, json=payload)
response.raise_for_status()

print(response.text)
const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/`;

const options = {
method: 'POST',
headers: {
"Content-Type": `application/json`,
"x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
},
body: JSON.stringify({
"name": "new_project_name",
"description": "string",
"components_list": [],
"flows_list": []
}),
};

fetch(url, options)
.then(async (response) => {
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const text = await response.text();
console.log(text);
})
.catch((error) => console.error(error));
curl -X POST \
"$LANGFLOW_URL/api/v1/projects/" \
-H "Content-Type: application/json" \
-H "x-api-key: $LANGFLOW_API_KEY" \
-d '{
"name": "new_project_name",
"description": "string",
"components_list": [],
"flows_list": []
}'
Result
{
"name": "new_project_name",
"description": "string",
"id": "b408ddb9-6266-4431-9be8-e04a62758331",
"parent_id": null
}

To add flows and components at project creation, retrieve the components_list and flows_list values from the /all and /flows/read endpoints and add them to the request body.

Adding a flow to a project moves the flow from its previous location. The flow isn't copied.

import os

import requests

url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/projects/"

headers = {
"accept": "application/json",
"Content-Type": "application/json",
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
}

payload = {
"name": "new_project_name",
"description": "string",
"components_list": ["3fa85f64-5717-4562-b3fc-2c963f66afa6"],
"flows_list": ["3fa85f64-5717-4562-b3fc-2c963f66afa6"],
}

response = requests.request("POST", url, headers=headers, json=payload)
response.raise_for_status()

print(response.text)
const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/`;

const options = {
method: 'POST',
headers: {
"accept": `application/json`,
"Content-Type": `application/json`,
"x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
},
body: JSON.stringify({
"name": "new_project_name",
"description": "string",
"components_list": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
],
"flows_list": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
]
}),
};

fetch(url, options)
.then(async (response) => {
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const text = await response.text();
console.log(text);
})
.catch((error) => console.error(error));
curl -X POST \
"$LANGFLOW_URL/api/v1/projects/" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "x-api-key: $LANGFLOW_API_KEY" \
-d '{
"name": "new_project_name",
"description": "string",
"components_list": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
],
"flows_list": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
]
}'

Read project​

Retrieve details of a specific project.

To find the UUID of your project, call the read projects endpoint.

import os

import requests

url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/projects/{os.getenv('PROJECT_ID', '')}"

headers = {
"accept": "application/json",
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
}

response = requests.request("GET", url, headers=headers)
response.raise_for_status()

print(response.text)
const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/${process.env.PROJECT_ID ?? ""}`;

const options = {
method: 'GET',
headers: {
"accept": `application/json`,
"x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
},
};

fetch(url, options)
.then(async (response) => {
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const text = await response.text();
console.log(text);
})
.catch((error) => console.error(error));
curl -X GET \
"$LANGFLOW_URL/api/v1/projects/$PROJECT_ID" \
-H "accept: application/json" \
-H "x-api-key: $LANGFLOW_API_KEY"
Result
[
{
"name": "Starter Project",
"description": "Manage your own projects. Download and upload projects.",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"parent_id": null
}
]

Update project​

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

Each PATCH request updates the project 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.

import os
import uuid

import requests

base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "")
project_id = os.environ.get("PROJECT_ID", "")
api_key = os.environ.get("LANGFLOW_API_KEY", "")

headers = {"accept": "application/json", "Content-Type": "application/json", "x-api-key": api_key}

payload = {
"name": f"docs-example-renamed-project-{uuid.uuid4().hex[:8]}",
"description": "Updated via API docs Python example",
}

response = requests.patch(f"{base}/api/v1/projects/{project_id}", headers=headers, json=payload, timeout=30)
response.raise_for_status()
print(response.text)
const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/b408ddb9-6266-4431-9be8-e04a62758331`;

const options = {
method: 'PATCH',
headers: {
"accept": `application/json`,
"x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
},
body: JSON.stringify({
"name": "string",
"description": "string",
"parent_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"components": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
],
"flows": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
]
}),
};

fetch(url, options)
.then(async (response) => {
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const text = await response.text();
console.log(text);
})
.catch((error) => console.error(error));
curl -X PATCH \
"$LANGFLOW_URL/api/v1/projects/b408ddb9-6266-4431-9be8-e04a62758331" \
-H "accept: application/json" \
-H "x-api-key: $LANGFLOW_API_KEY" \
-d '{
"name": "string",
"description": "string",
"parent_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"components": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
],
"flows": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
]
}'
Result
{
"name": "string",
"description": "string",
"id": "b408ddb9-6266-4431-9be8-e04a62758331",
"parent_id": null
}

Delete project​

Delete a specific project.

import os

import requests

base = os.environ.get("LANGFLOW_URL", "")
api_key = os.environ.get("LANGFLOW_API_KEY", "")

headers = {"accept": "*/*", "Content-Type": "application/json", "x-api-key": api_key}

create = requests.post(
f"{base}/api/v1/projects/",
headers=headers,
json={
"name": "docs-example-delete-me",
"description": "Temporary project",
"components_list": [],
"flows_list": [],
},
timeout=30,
)
create.raise_for_status()
project_id = create.json()["id"]

delete = requests.delete(f"{base}/api/v1/projects/{project_id}", headers=headers, timeout=30)
delete.raise_for_status()
print(delete.text)
const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/${process.env.PROJECT_ID ?? ""}`;

const options = {
method: 'DELETE',
headers: {
"accept": `*/*`,
"x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
},
};

fetch(url, options)
.then(async (response) => {
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const text = await response.text();
console.log(text);
})
.catch((error) => console.error(error));
curl -X DELETE \
"$LANGFLOW_URL/api/v1/projects/$PROJECT_ID" \
-H "accept: */*" \
-H "x-api-key: $LANGFLOW_API_KEY"
Result
204 No Content

Export a project​

Download all flows from a project as a zip file.

The --output flag is optional.

import os

import requests

url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/projects/download/{os.getenv('PROJECT_ID', '')}"

headers = {
"accept": "application/json",
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
}

response = requests.request("GET", url, headers=headers)
response.raise_for_status()

with open("langflow-project.zip", "wb") as f:
f.write(response.content)
print("Saved response to langflow-project.zip")
const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/download/${process.env.PROJECT_ID ?? ""}`;

const options = {
method: 'GET',
headers: {
"accept": `application/json`,
"x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
},
};

fetch(url, options)
.then(async (response) => {
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const data = await response.arrayBuffer();
console.log("Received binary response for langflow-project.zip", data.byteLength);
})
.catch((error) => console.error(error));
curl -X GET \
"$LANGFLOW_URL/api/v1/projects/download/$PROJECT_ID" \
-H "accept: application/json" \
-H "x-api-key: $LANGFLOW_API_KEY" \
--output langflow-project.zip

Import a project​

Import a project and its flows by uploading a Langflow project zip file:

import os
from pathlib import Path

import requests

base = os.environ.get("LANGFLOW_URL", "")
api_key = os.environ.get("LANGFLOW_API_KEY", "")

fixtures = Path(__file__).resolve().parents[2] / "fixtures"
default_json = fixtures / "project-import.json"
import_path = Path(os.environ.get("PROJECT_IMPORT_JSON", str(default_json)))

headers = {"accept": "application/json", "x-api-key": api_key}

files = {"file": (import_path.name, import_path.read_bytes(), "application/json")}
response = requests.post(f"{base}/api/v1/projects/upload/", headers=headers, files=files, timeout=60)

response.raise_for_status()
print(response.text)
const fs = require("fs");
const path = require("path");

const fixturesDir = path.join(__dirname, "../../fixtures");
const defaultProjectZip = path.join(fixturesDir, "project-import.zip");
const projectPath = process.env.PROJECT_IMPORT_FILE || defaultProjectZip;
const projectBuf = fs.readFileSync(projectPath);
const projectName = path.basename(projectPath);

const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/upload/`;

const formData = new FormData();
formData.append("file", new Blob([projectBuf], { type: "application/zip" }), projectName);

const options = {
method: "POST",
headers: {
accept: "application/json",
"x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`,
},
body: formData,
};

fetch(url, options)
.then(async (response) => {
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const text = await response.text();
console.log(text);
})
.catch((error) => console.error(error));
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DEFAULT_PROJECT_IMPORT_FILE="$SCRIPT_DIR/../../fixtures/project-import.json"
PROJECT_IMPORT_FILE="${PROJECT_IMPORT_JSON:-${PROJECT_IMPORT_FILE:-$DEFAULT_PROJECT_IMPORT_FILE}}"

curl -X POST \
"$LANGFLOW_URL/api/v1/projects/upload/" \
-H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-H "x-api-key: $LANGFLOW_API_KEY" \
-F "file=@${PROJECT_IMPORT_FILE};type=application/json"

Was this page helpful?

Support
Search