跳到主要内容

用户端点

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

user_id 值专门用于 Langflow 的用户系统,它存储在 Langflow 数据库中并通过 /users API 端点进行管理。 Langflow 数据库中的 user_id 主键映射到 API 中的 id 值。

添加用户

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

这会为用户的 id 创建一个新的 UUID,它映射到 Langflow 数据库中的 user_id


_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
}'

结果

_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
}

列出所有用户

获取系统中所有用户的分页列表。 只有超级用户可以使用此端点(is_superuser: true)。


_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 请求修改现有用户的信息。

此示例将用户 10c1c6a2-ab8a-4748-8700-0e4832fd5ce8 设置为活跃的超级用户。


_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
}'

结果

_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
}

删除用户

从系统中删除用户账户。

只有超级用户可以使用此端点(is_superuser: true)。


_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"

结果

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

Search