setMyDefaultAdministratorRights
Set the bot's default administrator rights when added as an administrator.
Request
POST /:token/setmydefaultadministratorrights
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| rights | ChatAdministratorRights | No | Default administrator rights object for the bot. If not specified, the previously set default rights will be cleared |
| for_channels | Boolean | No | If set to true, sets the default administrator rights for channels; otherwise sets the default administrator rights for groups and supergroups. Defaults to false |
ChatAdministratorRights Object
| Field | Type | Description |
|---|---|---|
| is_anonymous | Boolean | Whether the administrator's actions should be anonymous |
| can_manage_chat | Boolean | Whether the administrator can manage the chat |
| can_delete_messages | Boolean | Whether the administrator can delete messages |
| can_manage_video_chats | Boolean | Whether the administrator can manage video chats |
| can_restrict_members | Boolean | Whether the administrator can restrict members |
| can_promote_members | Boolean | Whether the administrator can promote members to administrators |
| can_change_info | Boolean | Whether the administrator can change chat information |
| can_invite_users | Boolean | Whether the administrator can invite users |
| can_post_messages | Boolean | Whether the administrator can post messages in the channel (channels only) |
| can_edit_messages | Boolean | Whether the administrator can edit messages in the channel (channels only) |
| can_pin_messages | Boolean | Whether the administrator can pin messages (groups and supergroups only) |
Response
Returns Boolean true on success.
json
{
"ok": true,
"result": true
}Error Codes
| Code | Description |
|---|---|
| 400 | Bad request parameters, such as invalid rights format |
| 401 | Invalid or expired token |
| 500 | Internal server error |
Example
cURL
Set default administrator rights for groups
bash
curl -X POST "https://api.example.com/<token>/setmydefaultadministratorrights" \
-H "Content-Type: application/json" \
-d '{
"rights": {
"is_anonymous": false,
"can_manage_chat": true,
"can_delete_messages": true,
"can_manage_video_chats": false,
"can_restrict_members": true,
"can_promote_members": false,
"can_change_info": false,
"can_invite_users": true,
"can_pin_messages": true
}
}'Set default administrator rights for channels
bash
curl -X POST "https://api.example.com/<token>/setmydefaultadministratorrights" \
-H "Content-Type: application/json" \
-d '{
"rights": {
"is_anonymous": false,
"can_manage_chat": true,
"can_delete_messages": true,
"can_post_messages": true,
"can_edit_messages": true,
"can_invite_users": true
},
"for_channels": true
}'Clear default administrator rights
bash
curl -X POST "https://api.example.com/<token>/setmydefaultadministratorrights" \
-H "Content-Type: application/json" \
-d '{}'