deleteChatPhoto
Returns: TrueOfficial docs ↗
Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
Parameters
chat_idIntegerStringRequiredUnique identifier for the target chat or username of the target channel (in the format
@channelusername)Returns
On success, True is returned.
GramIO Usage
ts
// Delete a chat photo by numeric ID
await bot.api.deleteChatPhoto({
chat_id: -1001234567890,
});ts
// Delete a channel photo by username
await bot.api.deleteChatPhoto({
chat_id: "@mychannel",
});ts
// Admin command to remove the current chat photo
bot.command("removephoto", async (ctx) => {
await bot.api.deleteChatPhoto({ chat_id: ctx.chatId });
await ctx.send("Chat photo has been removed.");
});Errors
| Code | Error | Cause |
|---|---|---|
| 400 | Bad Request: chat not found | chat_id is invalid or the bot cannot access this chat |
| 400 | Bad Request: CHAT_NOT_MODIFIED | The chat already has no photo — nothing to delete |
| 400 | Bad Request: can't change chat photo for private chats | This method only works in groups, supergroups, and channels |
| 403 | Forbidden: not enough rights | Bot is not an admin or lacks the can_change_info administrator right |
| 403 | Forbidden: bot is not a member of the channel chat | Bot has no access to the specified channel |
| 429 | Too Many Requests: retry after N | Rate limit hit — check retry_after, use auto-retry plugin |
Tips & Gotchas
- Private chats are not supported. This method only applies to groups, supergroups, and channels. There is no API method to remove a photo from a private (DM) chat.
- Bot must be admin with
can_change_info. The bot needs to be a chat administrator and have thecan_change_inforight specifically — general admin status alone is not enough if this right is absent. - Accepts
@usernamefor public chats. For public channels and supergroups you can pass@channelusernameinstead of the numeric ID — useful for bots that manage well-known channels. - No need to delete before updating. If you want to replace the photo, just call
setChatPhotodirectly — it overwrites the current photo without requiring a deletion first.
See Also
- setChatPhoto — upload a new chat photo
- getChat — get chat details including current photo