Skip to content

closeForumTopic

Returns: TrueOfficial docs ↗

Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.

Parameters

chat_idIntegerStringRequired
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
message_thread_idIntegerRequired
Unique identifier for the target message thread of the forum topic

Returns

On success, True is returned.

GramIO Usage

ts
// Close a forum topic by chat ID and thread ID
await 
bot
.
api
.
closeForumTopic
({
chat_id
: "@mysupergroup",
message_thread_id
: 123,
});
ts
// Close the topic that triggered the current message
bot
.
on
("message", async (
ctx
) => {
if (
ctx
.
threadId
&&
ctx
.
chat
?.
type
=== "supergroup") {
await
bot
.
api
.
closeForumTopic
({
chat_id
:
ctx
.
chatId
,
message_thread_id
:
ctx
.
threadId
,
}); await
ctx
.
send
("This topic has been closed.");
} });
ts
// Admin command to close a topic using a numeric ID from user input
bot
.
command
("closetopic", async (
ctx
) => {
const
threadId
=
Number
(
ctx
.
args
);
if (!
threadId
) {
return
ctx
.
reply
("Usage: /closetopic <thread_id>");
} await
bot
.
api
.
closeForumTopic
({
chat_id
:
ctx
.
chatId
,
message_thread_id
:
threadId
,
}); await
ctx
.
reply
(`Topic ${
threadId
} has been closed.`);
});

Errors

CodeErrorCause
400Bad Request: chat not foundchat_id is invalid or the bot has no access to the chat
400Bad Request: TOPIC_NOT_MODIFIEDThe topic is already closed — no action taken
400Bad Request: message thread not foundmessage_thread_id does not exist in this chat
403Forbidden: not enough rightsBot is not an admin or lacks can_manage_topics right, and is not the topic creator
400Bad Request: supergroup requiredForum topics only exist in supergroups with forum mode enabled

Tips & Gotchas

  • Forum mode must be enabled. The chat must be a supergroup with forum mode active. Calling this on a regular group or channel returns an error.
  • Topic creator exemption. The bot can close a topic it created without can_manage_topics admin rights. For topics created by others, the bot needs the right explicitly.
  • General topic uses a different method. The 'General' topic cannot be closed with closeForumTopic — use closeGeneralForumTopic instead.
  • message_thread_id is the topic ID. In GramIO contexts, access it via ctx.threadId. Messages sent to a topic carry this ID.
  • Closing doesn't delete the topic. Users can still read the conversation; new messages simply cannot be posted. Use deleteForumTopic to remove the topic entirely.

See Also