Skip to content

unbanChatMember

Unban a previously banned user from the chat.

Request

POST /:token/unbanchatmember

Parameters

ParameterTypeRequiredDescription
chat_idInteger/StringYesUnique identifier or username of the target chat
user_idIntegerYesUnique identifier of the user to be unbanned
only_if_bannedBooleanNoIf set to true, the unban operation is only performed if the user is currently banned. This prevents accidentally removing a non-banned user from the chat

Response

Returns Boolean true on success.

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

Error Codes

CodeDescription
400Bad request parameters, such as missing chat_id or user_id
401Invalid or expired token
403Bot does not have administrator privileges or permission to unban users
404Chat or user not found
500Internal server error

Example

cURL

Unban a user

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

Unban only if currently banned

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