跳到主要内容

用户端点

使用 /users 端点来管理 Langflow 中的用户账户。

添加用户

使用给定的用户名和密码创建新用户账户。

如果 Langflow 服务器启用了身份验证,则需要超级用户身份验证。


_10
curl -X POST \
_10
"$LANGFLOW_URL/api/v1/users/" \
_10
-H "Content-Type: application/json" \
_10
-H "x-api-key: $LANGFLOW_API_KEY" \
_10
-d '{
_10
"username": "newuser2",
_10
"password": "securepassword123"
_10
}'

请求返回一个描述新用户对象。 用户的 UUID 存储在 Langflow 数据库的 user_id 中,并在 /users API 响应中作为 id 返回。 这个 user_id 键专门用于 Langflow 用户管理。

结果

_16
{
_16
"id": "10c1c6a2-ab8a-4748-8700-0e4832fd5ce8",
_16
"username": "newuser2",
_16
"profile_image": null,
_16
"store_api_key": null,
_16
"is_active": false,
_16
"is_superuser": false,
_16
"create_at": "2025-05-29T16:02:20.132436",
_16
"updated_at": "2025-05-29T16:02:20.132442",
_16
"last_login_at": null,
_16
"optins": {
_16
"github_starred": false,
_16
"dialog_dismissed": false,
_16
"discord_clicked": false
_16
}
_16
}

获取当前用户

获取已认证用户的信息。


_10
curl -X GET \
_10
"$LANGFLOW_URL/api/v1/users/whoami" \
_10
-H "accept: application/json" \
_10
-H "x-api-key: $LANGFLOW_API_KEY"

结果

_11
{
_11
"id": "07e5b864-e367-4f52-b647-a48035ae7e5e",
_11
"username": "langflow",
_11
"profile_image": null,
_11
"store_api_key": null,
_11
"is_active": true,
_11
"is_superuser": true,
_11
"create_at": "2025-05-08T17:59:07.855965",
_11
"updated_at": "2025-05-29T15:06:56.157860",
_11
"last_login_at": "2025-05-29T15:06:56.157016",
_11
}

列出所有用户

获取系统中所有用户的分页列表。

如果 Langflow 服务器启用了身份验证,则需要超级用户身份验证。


_10
curl -X GET \
_10
"$LANGFLOW_URL/api/v1/users/?skip=0&limit=10" \
_10
-H "accept: application/json" \
_10
-H "x-api-key: $LANGFLOW_API_KEY"

结果

_54
{
_54
"total_count": 3,
_54
"users": [
_54
{
_54
"id": "07e5b864-e367-4f52-b647-a48035ae7e5e",
_54
"username": "langflow",
_54
"profile_image": null,
_54
"store_api_key": null,
_54
"is_active": true,
_54
"is_superuser": true,
_54
"create_at": "2025-05-08T17:59:07.855965",
_54
"updated_at": "2025-05-29T15:06:56.157860",
_54
"last_login_at": "2025-05-29T15:06:56.157016",
_54
"optins": {
_54
"github_starred": false,
_54
"dialog_dismissed": true,
_54
"discord_clicked": false,
_54
"mcp_dialog_dismissed": true
_54
}
_54
},
_54
{
_54
"id": "c48a1f68-cc7e-491a-a507-a1a627708470",
_54
"username": "newuser",
_54
"profile_image": null,
_54
"store_api_key": null,
_54
"is_active": false,
_54
"is_superuser": false,
_54
"create_at": "2025-05-29T16:00:33.483386",
_54
"updated_at": "2025-05-29T16:00:33.483392",
_54
"last_login_at": null,
_54
"optins": {
_54
"github_starred": false,
_54
"dialog_dismissed": false,
_54
"discord_clicked": false
_54
}
_54
},
_54
{
_54
"id": "10c1c6a2-ab8a-4748-8700-0e4832fd5ce8",
_54
"username": "newuser2",
_54
"profile_image": null,
_54
"store_api_key": null,
_54
"is_active": false,
_54
"is_superuser": false,
_54
"create_at": "2025-05-29T16:02:20.132436",
_54
"updated_at": "2025-05-29T16:02:20.132442",
_54
"last_login_at": null,
_54
"optins": {
_54
"github_starred": false,
_54
"dialog_dismissed": false,
_54
"discord_clicked": false
_54
}
_54
}
_54
]
_54
}

更新用户

使用 PATCH 请求修改现有用户的信息。

如果 Langflow 服务器启用了身份验证,则需要超级用户身份验证。

此示例激活指定用户的账户并将其设为超级用户:


_10
curl -X PATCH \
_10
"$LANGFLOW_URL/api/v1/users/10c1c6a2-ab8a-4748-8700-0e4832fd5ce8" \
_10
-H "Content-Type: application/json" \
_10
-H "x-api-key: $LANGFLOW_API_KEY" \
_10
-d '{
_10
"is_active": true,
_10
"is_superuser": true
_10
}'

结果

_16
{
_16
"id": "10c1c6a2-ab8a-4748-8700-0e4832fd5ce8",
_16
"username": "newuser2",
_16
"profile_image": null,
_16
"store_api_key": null,
_16
"is_active": true,
_16
"is_superuser": true,
_16
"create_at": "2025-05-29T16:02:20.132436",
_16
"updated_at": "2025-05-29T16:19:03.514527Z",
_16
"last_login_at": null,
_16
"optins": {
_16
"github_starred": false,
_16
"dialog_dismissed": false,
_16
"discord_clicked": false
_16
}
_16
}

重置密码

将指定用户的密码更改为新的安全值。

需要以目标用户身份进行身份验证。


_10
curl -X PATCH \
_10
"$LANGFLOW_URL/api/v1/users/10c1c6a2-ab8a-4748-8700-0e4832fd5ce8/reset-password" \
_10
-H "Content-Type: application/json" \
_10
-H "x-api-key: $LANGFLOW_API_KEY" \
_10
-d '{
_10
"password": "newsecurepassword123"
_10
}'

Result

_16
{
_16
"id": "10c1c6a2-ab8a-4748-8700-0e4832fd5ce8",
_16
"username": "langflow",
_16
"profile_image": null,
_16
"store_api_key": null,
_16
"is_active": true,
_16
"is_superuser": true,
_16
"create_at": "2025-05-08T17:59:07.855965",
_16
"updated_at": "2025-05-29T15:06:56.157860",
_16
"last_login_at": "2025-05-29T15:06:56.157016",
_16
"optins": {
_16
"github_starred": false,
_16
"dialog_dismissed": true,
_16
"discord_clicked": false
_16
}
_16
}

删除用户

从系统中删除用户账户。

如果 Langflow 服务器启用了身份验证,则需要以超级用户身份进行身份验证。


_10
curl -X DELETE \
_10
"$LANGFLOW_URL/api/v1/users/10c1c6a2-ab8a-4748-8700-0e4832fd5ce8" \
_10
-H "accept: application/json" \
_10
-H "x-api-key: $LANGFLOW_API_KEY"

Result

_10
{
_10
"detail": "User deleted"
_10
}

Search