Skip to content

restrictChatMember

Restrict a chat member's permissions.

Request

POST /:token/restrictchatmember

Parameters

ParameterTypeRequiredDescription
chat_idInteger/StringYesUnique identifier or username of the target chat
user_idIntegerYesUnique identifier of the target user
permissionsChatPermissionsYesNew permissions for the user
until_dateIntegerNoUnix timestamp for the restriction expiration date. If set to 0 or omitted, the user is restricted permanently. Restrictions shorter than 30 seconds or longer than 366 days are treated as permanent

ChatPermissions Object

FieldTypeDescription
can_send_messagesBooleanWhether the user is allowed to send text messages, contacts, locations, and venues
can_send_media_messagesBooleanWhether the user is allowed to send audio, documents, photos, videos, video notes, and voice notes
can_send_pollsBooleanWhether the user is allowed to send polls
can_send_other_messagesBooleanWhether the user is allowed to send animations, games, stickers, and use inline bots
can_add_web_page_previewsBooleanWhether the user is allowed to add web page link previews
can_change_infoBooleanWhether the user is allowed to change the chat title, photo, and other settings
can_invite_usersBooleanWhether the user is allowed to invite new users to the chat
can_pin_messagesBooleanWhether the user is allowed to pin messages

Response

Returns Boolean true on success.

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

Error Codes

CodeDescription
400Bad request parameters, such as missing required parameters or invalid permissions format
401Invalid or expired token
403Bot does not have administrator privileges or permission to restrict members
404Chat or user not found
500Internal server error

Example

cURL

Mute a user (restrict all messages)

bash
curl -X POST "https://api.example.com/<token>/restrictchatmember" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": -1001234567890,
    "user_id": 987654321,
    "permissions": {
      "can_send_messages": false,
      "can_send_media_messages": false,
      "can_send_polls": false,
      "can_send_other_messages": false,
      "can_add_web_page_previews": false,
      "can_change_info": false,
      "can_invite_users": false,
      "can_pin_messages": false
    }
  }'

Temporarily restrict a user (allow text messages only, for 24 hours)

bash
curl -X POST "https://api.example.com/<token>/restrictchatmember" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": -1001234567890,
    "user_id": 987654321,
    "permissions": {
      "can_send_messages": true,
      "can_send_media_messages": false,
      "can_send_polls": false,
      "can_send_other_messages": false,
      "can_add_web_page_previews": false,
      "can_change_info": false,
      "can_invite_users": false,
      "can_pin_messages": false
    },
    "until_date": 1700086400
  }'