Skip to content

unpinAllGeneralForumTopicMessages

Returns: TrueOfficial docs ↗

Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.

Parameters

chat_idIntegerStringRequired
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)

Returns

On success, True is returned.

GramIO Usage

Clear all pinned messages from the General forum topic:

ts
await 
bot
.
api
.
unpinAllGeneralForumTopicMessages
({
chat_id
: -1001234567890,
});

Handle a /cleargeneral command to clear pins from the General topic:

ts
bot
.
command
("cleargeneral", async (
ctx
) => {
await
bot
.
api
.
unpinAllGeneralForumTopicMessages
({
chat_id
:
ctx
.
chat
.
id
,
}); await
ctx
.
send
("All pinned messages in the General topic have been cleared.");
});

Clear General topic pins in a supergroup by username:

ts
async function 
clearGeneralTopicPins
(
supergroupUsername
: string) {
await
bot
.
api
.
unpinAllGeneralForumTopicMessages
({
chat_id
: `@${
supergroupUsername
}`,
}); }

Errors

CodeErrorCause
400Bad Request: chat not foundchat_id is invalid or the bot is not a member of the chat
400Bad Request: method is available only for supergroupsThe target chat is not a forum supergroup with topics enabled
403Forbidden: bot is not an administratorThe bot has no admin status in the chat
403Forbidden: not enough rights to pin messagesThe bot is an admin but lacks can_pin_messages in the supergroup
429Too Many Requests: retry after NRate limit hit — check retry_after, use the auto-retry plugin

TIP

Use GramIO's auto-retry plugin to handle 429 errors automatically.

Tips & Gotchas

  • The General topic is always thread ID 1. This method targets it specifically without you needing to specify the thread ID. For all other custom topics use unpinAllForumTopicMessages with the appropriate message_thread_id.
  • Requires can_pin_messages — not can_manage_topics. Pinning/unpinning needs the pin right even in the General topic.
  • Forum mode must be enabled. This method only works in supergroups where the Topics feature is active. Regular supergroups and other chat types return an error.
  • Messages are not deleted. Unpinning removes messages from the pinned list but leaves them in the General topic history.
  • Works even when the General topic is hidden. Admins can manage pins regardless of whether the General topic is currently visible to members.

See Also