Users
获取用户
get /v1/organizations/users/{user_id}
获取用户
路径参数
-
user_id: string用户的 ID。
返回值
-
User object { id, added_at, email, 3 more }-
id: string用户的 ID。
-
added_at: stringRFC 3339 日期时间字符串,表示用户加入组织的时间。
-
email: string用户的邮箱。
-
name: string用户的姓名。
-
role: "user" or "developer" or "billing" or 2 more用户在组织中的角色。
-
"user" -
"developer" -
"billing" -
"admin" -
"claude_code_user"
-
-
type: "user"对象类型。
对于用户,始终为
"user"。"user"
-
示例
curl https://api.anthropic.com/v1/organizations/users/$USER_ID \
-H 'anthropic-version: 2023-06-01' \
-H "X-Api-Key: $ANTHROPIC_ADMIN_API_KEY"
响应
{
"id": "user_01WCz1FkmYMm4gnmykNKUu3Q",
"added_at": "2024-10-30T23:58:27.427722Z",
"email": "user@emaildomain.com",
"name": "Jane Doe",
"role": "user",
"type": "user"
}
列出用户
get /v1/organizations/users
列出用户
查询参数
-
after_id: optional string用作分页游标的对象 ID。提供后,将返回该对象之后的结果页。
-
before_id: optional string用作分页游标的对象 ID。提供后,将返回该对象之前的结果页。
-
email: optional string按用户邮箱筛选。
-
limit: optional number每页返回的条目数。
默认为
20。范围为1到1000。
返回值
-
data: array of User-
id: string用户的 ID。
-
added_at: stringRFC 3339 日期时间字符串,表示用户加入组织的时间。
-
email: string用户的邮箱。
-
name: string用户的姓名。
-
role: "user" or "developer" or "billing" or 2 more用户在组织中的角色。
-
"user" -
"developer" -
"billing" -
"admin" -
"claude_code_user"
-
-
type: "user"对象类型。
对于用户,始终为
"user"。"user"
-
-
first_id: stringdata列表中的第一个 ID。可用作上一页的before_id。 -
has_more: boolean指示在请求的分页方向上是否还有更多结果。
-
last_id: stringdata列表中的最后一个 ID。可用作下一页的after_id。
示例
curl https://api.anthropic.com/v1/organizations/users \
-H 'anthropic-version: 2023-06-01' \
-H "X-Api-Key: $ANTHROPIC_ADMIN_API_KEY"
响应
{
"data": [
{
"id": "user_01WCz1FkmYMm4gnmykNKUu3Q",
"added_at": "2024-10-30T23:58:27.427722Z",
"email": "user@emaildomain.com",
"name": "Jane Doe",
"role": "user",
"type": "user"
}
],
"first_id": "first_id",
"has_more": true,
"last_id": "last_id"
}
更新用户
post /v1/organizations/users/{user_id}
更新用户
路径参数
-
user_id: string用户的 ID。
请求体参数
-
role: "user" or "developer" or "billing" or "claude_code_user"用户的新角色。不能为 "admin"。
-
"user" -
"developer" -
"billing" -
"claude_code_user"
-
返回值
-
User object { id, added_at, email, 3 more }-
id: string用户的 ID。
-
added_at: stringRFC 3339 日期时间字符串,表示用户加入组织的时间。
-
email: string用户的邮箱。
-
name: string用户的姓名。
-
role: "user" or "developer" or "billing" or 2 more用户在组织中的角色。
-
"user" -
"developer" -
"billing" -
"admin" -
"claude_code_user"
-
-
type: "user"对象类型。
对于用户,始终为
"user"。"user"
-
示例
curl https://api.anthropic.com/v1/organizations/users/$USER_ID \
-H 'Content-Type: application/json' \
-H 'anthropic-version: 2023-06-01' \
-H "X-Api-Key: $ANTHROPIC_ADMIN_API_KEY" \
-d '{
"role": "user"
}'
响应
{
"id": "user_01WCz1FkmYMm4gnmykNKUu3Q",
"added_at": "2024-10-30T23:58:27.427722Z",
"email": "user@emaildomain.com",
"name": "Jane Doe",
"role": "user",
"type": "user"
}
移除用户
delete /v1/organizations/users/{user_id}
移除用户
路径参数
-
user_id: string用户的 ID。
返回值
-
id: string用户的 ID。
-
type: "user_deleted"已删除的对象类型。
对于用户,始终为
"user_deleted"。"user_deleted"
示例
curl https://api.anthropic.com/v1/organizations/users/$USER_ID \
-X DELETE \
-H 'anthropic-version: 2023-06-01' \
-H "X-Api-Key: $ANTHROPIC_ADMIN_API_KEY"
响应
{
"id": "user_01WCz1FkmYMm4gnmykNKUu3Q",
"type": "user_deleted"
}
领域类型
User
-
User object { id, added_at, email, 3 more }-
id: string用户的 ID。
-
added_at: stringRFC 3339 日期时间字符串,表示用户加入组织的时间。
-
email: string用户的邮箱。
-
name: string用户的姓名。
-
role: "user" or "developer" or "billing" or 2 more用户在组织中的角色。
-
"user" -
"developer" -
"billing" -
"admin" -
"claude_code_user"
-
-
type: "user"对象类型。
对于用户,始终为
"user"。"user"
-
User Delete Response
-
UserDeleteResponse object { id, type }-
id: string用户的 ID。
-
type: "user_deleted"已删除的对象类型。
对于用户,始终为
"user_deleted"。"user_deleted"
-