Skip to content

unbanChatMember

解除用户的封禁。

请求

POST /:token/unbanchatmember

参数

参数类型必填描述
chat_idInteger/String目标聊天的唯一标识符或用户名
user_idInteger要解封的用户的唯一标识符
only_if_bannedBoolean如果设为 true,则仅在用户已被封禁时才执行解封操作。避免将未封禁用户意外移出群聊

响应

成功时返回 Boolean 值 true

json
{
  "ok": true,
  "result": true
}

错误码

错误码描述
400请求参数错误,如缺少 chat_id 或 user_id
401Token 无效或已过期
403Bot 没有管理员权限或没有解封用户的权限
404聊天或用户不存在
500服务器内部错误

示例

cURL

解封用户

bash
curl -X POST "https://api.example.com/<token>/unbanchatmember" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": -1001234567890,
    "user_id": 987654321
  }'

仅在已封禁时解封

bash
curl -X POST "https://api.example.com/<token>/unbanchatmember" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": -1001234567890,
    "user_id": 987654321,
    "only_if_banned": true
  }'