Telegram Bot API: manage group membership and moderation
domain: telegram.org · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
Steps
Create a bot via BotFather, add it to the target group/supergroup, and promote it to admin with the specific rights needed (e.g. ban/restrict members) — the Bot API enforces these rights server-side.
Ban a member with banChatMember(chat_id, user_id), optionally setting until_date for a temporary ban (values under 30s or over 366 days are treated as permanent) and revoke_messages to also delete their prior messages.
Restrict (mute/limit) a member in a supergroup with restrictChatMember(chat_id, user_id, permissions, until_date) instead of a full ban.
Reverse a ban with unbanChatMember; by default this also removes the user if still present, so pass only_if_banned:true to just lift a ban without kicking a current member.
Check current status/role with getChatMember or getChatAdministrators before acting, since every moderation call requires the bot to already hold that specific admin right.
Known gotchas
restrictChatMember only works in supergroups, not basic groups or channels — moderation flows must branch on chat type.
unbanChatMember's default behavior (removing an already-present member) surprises many integrators — use only_if_banned to avoid accidentally kicking someone who was never banned.
General 'is admin' status is not enough — the bot needs the exact right (e.g. can_restrict_members) granted for each specific action.
Give your agent this knowledge — and 15,500+ more routes
One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?