Skip to content

setChatTitle

Returns: TrueOfficial docs ↗

Use this method to change the title of a chat. Titles 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_idIntegerStringRequired
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
titleStringRequiredminLen 1maxLen 128
New chat title, 1-128 characters

Returns

On success, True is returned.

GramIO Usage

ts
// Rename the current chat from inside a command handler
bot
.
command
("rename", (
ctx
) =>
ctx
.
setChatTitle
("New Group Name")
);
ts
// Rename via direct API call — useful from outside a handler
await 
bot
.
api
.
setChatTitle
({
chat_id
: -1001234567890,
title
: "My Awesome Channel",
});
ts
// Rename a public channel by username
await 
bot
.
api
.
setChatTitle
({
chat_id
: "@mychannel",
title
: "Updated Channel Name",
});

Errors

CodeErrorCause
400Bad Request: chat not foundInvalid or inaccessible chat_id — verify the bot is a member
400Bad Request: not enough rights to change chat titleBot lacks the can_change_info administrator permission
400Bad Request: title is too longtitle exceeds 128 characters — trim before sending
400Bad Request: title can't be emptyEmpty string passed as title — minimum 1 character
400Bad Request: can't change title of private chatsAttempted to rename a private (DM) chat — not allowed
403Forbidden: bot is not a member of the channel chatBot is not in the channel — add it first
403Forbidden: not enough rightsBot was removed from admin or rights were revoked

Tips & Gotchas

  • Private chats cannot be renamed. This method only works for groups, supergroups, and channels. Calling it with a private chat chat_id always returns an error.
  • can_change_info right is required. Even if the bot is an admin, it must have this specific right. Check with getChatAdministrators if unsure.
  • chat_id accepts @username strings for public channels and supergroups. For private groups you must use the numeric ID.
  • Title length is 1–128 characters. Telegram strips leading/trailing whitespace on the client side, but the API enforces the byte length limit — multi-byte characters count as multiple bytes.
  • Rate limiting applies. Rapidly renaming a chat (e.g., in a loop) will trigger 429 Too Many Requests. Throttle rename operations or use the auto-retry plugin.

See Also