Use this method to restrict a user in a supergroup

POST /restrictChatMember

Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all permissions to lift restrictions from a user. Returns True on success.

Body Required

  • chat_id integer | string Required

    Any of:

    Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)

    Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)

  • user_id integer Required

    Unique identifier of the target user

  • permissions object Required

    Describes actions that a non-administrator user is allowed to take in a chat.

    Hide permissions attributes Show permissions attributes object
    • can_invite_users boolean

      Optional. True, if the user is allowed to invite new users to the chat

    • can_send_messages boolean

      Optional. True, if the user is allowed to send text messages, contacts, locations and venues

    • can_send_media_messages boolean

      Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages

    • can_send_polls boolean

      Optional. True, if the user is allowed to send polls, implies can_send_messages

    • can_send_other_messages boolean

      Optional. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages

    • can_add_web_page_previews boolean

      Optional. True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages

    • can_change_info boolean

      Optional. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups

    • can_pin_messages boolean

      Optional. True, if the user is allowed to pin messages. Ignored in public supergroups

  • until_date integer

    Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever

Responses

  • default
    Hide response attributes Show response attributes object
    • ok boolean Required

      Default value is false.

    • error_code integer Required
    • description string Required
    • parameters object

      Contains information about why a request was unsuccessful.

      Hide parameters attributes Show parameters attributes object
      • migrate_to_chat_id integer

        Optional. The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.

      • retry_after integer

        Optional. In case of exceeding flood control, the number of seconds left to wait before the request can be repeated

  • 200
    Hide response attributes Show response attributes object
    • ok boolean Required

      Default value is true.

    • result boolean Required

      Default value is true.

POST /restrictChatMember
curl \
 -X POST https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/restrictChatMember \
 -H "Content-Type: application/json" \
 -d '{"chat_id":42,"user_id":42,"permissions":{"can_send_messages":true,"can_send_media_messages":true,"can_send_polls":true,"can_send_other_messages":true,"can_add_web_page_previews":true,"can_change_info":true,"can_invite_users":true,"can_pin_messages":true},"until_date":42}'
Request example
{
  "chat_id": 42,
  "user_id": 42,
  "permissions": {
    "can_send_messages": true,
    "can_send_media_messages": true,
    "can_send_polls": true,
    "can_send_other_messages": true,
    "can_add_web_page_previews": true,
    "can_change_info": true,
    "can_invite_users": true,
    "can_pin_messages": true
  },
  "until_date": 42
}
Request examples
{
  "chat_id": 42,
  "user_id": 42,
  "permissions": {
    "can_invite_users": true,
    "can_send_messages": true,
    "can_send_media_messages": true,
    "can_send_polls": true,
    "can_send_other_messages": true,
    "can_add_web_page_previews": true,
    "can_change_info": true,
    "can_pin_messages": true
  },
  "until_date": 42
}
Response examples (default)
{
  "ok": false,
  "error_code": 42,
  "description": "string",
  "parameters": {
    "migrate_to_chat_id": 42,
    "retry_after": 42
  }
}
Response examples (default)
{
  "ok": false,
  "error_code": 42,
  "description": "string",
  "parameters": {
    "migrate_to_chat_id": 42,
    "retry_after": 42
  }
}
Response examples (200)
{
  "ok": true,
  "result": true
}
Response examples (200)
{
  "ok": true,
  "result": true
}