setChatAdministratorCustomTitle
Returns: TrueOfficial docs ↗
Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.
Parameters
chat_idIntegerStringRequiredUnique identifier for the target chat or username of the target supergroup (in the format
@supergroupusername)user_idIntegerRequiredUnique identifier of the target user
custom_titleStringRequiredminLen 0maxLen 16New custom title for the administrator; 0-16 characters, emoji are not allowed
Returns
On success, True is returned.
GramIO Usage
ts
// Set a custom title for a known admin
await bot.api.setChatAdministratorCustomTitle({
chat_id: -1001234567890,
user_id: 987654321,
custom_title: "Head of Support",
});ts
// Clear the custom title (pass an empty string)
await bot.api.setChatAdministratorCustomTitle({
chat_id: "@mysupergroup",
user_id: 987654321,
custom_title: "",
});ts
// From a message context — sets a custom title for the message sender
// (the sender must already be an admin promoted by the bot)
bot.command("settitle", async (ctx) => {
const title = ctx.text?.split(" ").slice(1).join(" ") ?? "";
await ctx.setCustomTitle(title);
await ctx.send("Title updated!");
});Errors
| Code | Error | Cause |
|---|---|---|
| 400 | Bad Request: chat not found | Invalid or inaccessible chat_id |
| 400 | Bad Request: USER_NOT_PARTICIPANT | The target user is not in the chat |
| 400 | Bad Request: USER_ADMIN_INVALID | The user was not promoted by this bot, or is not an admin |
| 400 | Bad Request: ADMIN_RANK_EMOJI_NOT_ALLOWED | custom_title contains one or more emoji characters |
| 400 | Bad Request: ADMIN_RANK_INVALID | custom_title exceeds 16 characters |
| 403 | Forbidden: not enough rights | Bot lacks the right to manage administrators |
| 403 | Forbidden: bot is not a member of the supergroup chat | Bot was removed from the supergroup |
Tips & Gotchas
- Bot must have promoted the user. You can only set a custom title for an administrator your bot promoted via
promoteChatMember. If the user was promoted by another admin or by Telegram, this call will fail withUSER_ADMIN_INVALID. - Emoji are strictly forbidden. The 0–16 character limit also excludes all emoji — passing any emoji character returns
ADMIN_RANK_EMOJI_NOT_ALLOWED. Plain ASCII and Unicode letters/punctuation are allowed. - Supergroups only. This method works exclusively in supergroups. Calling it on a regular group, channel, or private chat will return an error.
- Empty string clears the title. Passing
custom_title: ""removes any existing custom title and reverts to the default role badge. - Context shorthand is
ctx.setCustomTitle(title). Available inMessageContextand other contexts that includeChatControlMixin;chat_idanduser_idare inferred from the context.
See Also
promoteChatMember— promote a user to admin before setting a titlerestrictChatMember— restrict member permissionsbanChatMember— ban a member from the chatgetChat— retrieve chat info including admin list