Use this method to set default chat permissions for all members

POST /setChatPermissions

Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members admin rights. 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)

  • 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_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_invite_users boolean

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

    • can_pin_messages boolean

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

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 /setChatPermissions
curl \
 -X POST https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/setChatPermissions \
 -H "Content-Type: application/json" \
 -d '{"chat_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}}'
Request example
{
  "chat_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
  }
}
Request examples
{
  "chat_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
  }
}
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
}