# Telegram 400: Bad Request: group chat was upgraded to a supergroup chat — how to fix it

> The group your bot writes to was upgraded to a supergroup, and the supergroup has a new chat id: the old one no longer takes messages. The error carries the new id in parameters.migrate_to_chat_id. Save it in place of the old id and send again, and handle the migrate_to_chat_id service message so the id is updated before the next send fails.

Source: https://livops.dev/en/guides/error-telegram-group-chat-upgraded-to-supergroup

By Livops team, the people who build and run Livops. Updated 2 December 2026.

The error, as the Telegram Bot API returns it with error code 400[2]:

```text
Bad Request: group chat was upgraded to a supergroup chat
```

The response also carries the new chat id, in `parameters`[1][2]:

```json
{
  "ok": false,
  "error_code": 400,
  "description": "Bad Request: group chat was upgraded to a supergroup chat",
  "parameters": { "migrate_to_chat_id": -1001234567890 }
}
```

Each library wraps it in its own words:

| Library | What you see |
| --- | --- |
| aiogram 3 | `TelegramMigrateToChat: Telegram server says - The group has been migrated to a supergroup with id -1001234567890 from -123456789`[6][7] |
| python-telegram-bot | `telegram.error.ChatMigrated: Group migrated to supergroup. New chat id: -1001234567890`[9][10] |
| grammY | `GrammyError: Call to 'sendMessage' failed! (400: Bad Request: group chat was upgraded to a supergroup chat)`[13] |
| Telegraf | `TelegramError: 400: Bad Request: group chat was upgraded to a supergroup chat`[14] |

aiogram and python-telegram-bot raise their own exception for this case and print the new id; grammY and Telegraf keep Telegram's text and put the id on the error's `parameters`. This page explains why the id changed, shows how to read the new one and save it in each library, how to catch the change before a send fails, and what to check when the bot runs on Livops.

## What does the error mean?

Telegram has two kinds of group. A **basic group** is the simple one; a **supergroup** is the one with the bigger feature set. Upgrading a basic group creates a new supergroup, and Telegram's API documentation tells apps to do it automatically when an admin tries an action that only supergroups support[3]. For your bot, the result is a different chat with a different id, and all new messages have to be sent to the new supergroup[3].

The old id stays valid as an id, but the group behind it is no longer active. When a bot sends to it, the Bot API server answers `Bad Request: group chat was upgraded to a supergroup chat` and puts the supergroup's id into `parameters.migrate_to_chat_id`[2]. `parameters` is the optional `ResponseParameters` object that some errors carry to help you handle them automatically; `migrate_to_chat_id` is its field for "the group has been migrated to a supergroup with the specified identifier"[1].

So the fix is mechanical: read `migrate_to_chat_id`, replace the old id with it wherever you stored it, and send again.

## How to tell the two ids apart

The Bot API numbers chats so the kind can be read from the id[4]:

- **Basic group:** the internal id made negative, from `-999999999999` to `-1`.
- **Supergroup or channel:** `-(1000000000000 + id)`, from `-1997852516352` to `-1000000000001`.

So `-123456789` is a basic group, and `-1001234567890` is a supergroup or channel. The `Chat` object also says it directly: `type` is `group` or `supergroup`[1]. Ids can need more than 32 bits but at most 52, so store them as a 64-bit integer[1] — `BIGINT` in SQL.

## Fix it in each library

Each example catches the migration, saves the new id, and sends the same message once more. `save_chat_id(old, new)` stands for your own update, shown in SQL further down.

### aiogram 3

aiogram raises `TelegramMigrateToChat` whenever the response's `parameters` contain `migrate_to_chat_id`, and keeps the id on the exception[6][7]:

```python
from aiogram import Bot
from aiogram.exceptions import TelegramMigrateToChat


async def send(bot: Bot, chat_id: int, text: str) -> int:
    try:
        await bot.send_message(chat_id, text)
        return chat_id
    except TelegramMigrateToChat as e:
        new_id = e.migrate_to_chat_id
        await save_chat_id(chat_id, new_id)
        await bot.send_message(new_id, text)
        return new_id
```

### python-telegram-bot

python-telegram-bot raises `telegram.error.ChatMigrated` with the id in `new_chat_id`[9][10]:

```python
from telegram.error import ChatMigrated


async def send(bot, chat_id: int, text: str) -> int:
    try:
        await bot.send_message(chat_id, text)
        return chat_id
    except ChatMigrated as e:
        await save_chat_id(chat_id, e.new_chat_id)
        await bot.send_message(e.new_chat_id, text)
        return e.new_chat_id
```

### grammY

grammY throws a `GrammyError` that keeps Telegram's `parameters`[13]:

```ts
import { Bot, GrammyError } from "grammy";

async function send(bot: Bot, chatId: number, text: string): Promise<number> {
  try {
    await bot.api.sendMessage(chatId, text);
    return chatId;
  } catch (err) {
    const newId = err instanceof GrammyError
      ? err.parameters.migrate_to_chat_id
      : undefined;
    if (!newId) throw err;
    await saveChatId(chatId, newId);
    await bot.api.sendMessage(newId, text);
    return newId;
  }
}
```

### Telegraf

Telegraf throws a `TelegramError` whose `parameters` are Telegram's `ResponseParameters`[14]:

```js
const { TelegramError } = require('telegraf');

async function send(telegram, chatId, text) {
  try {
    await telegram.sendMessage(chatId, text);
    return chatId;
  } catch (err) {
    const newId = err instanceof TelegramError
      ? err.parameters?.migrate_to_chat_id
      : undefined;
    if (!newId) throw err;
    await saveChatId(chatId, newId);
    await telegram.sendMessage(newId, text);
    return newId;
  }
}
```

## Catch the upgrade before a send fails

When a group is migrated, Telegram posts a service message about it[3], and the Bot API passes it on as a `Message` with one of two fields[1]:

- `migrate_to_chat_id` — in the old group: "the group has been migrated to a supergroup with the specified identifier".
- `migrate_from_chat_id` — in the new supergroup: "the supergroup has been migrated from a group with the specified identifier".

All bots receive all service messages, whatever their privacy mode[5], so a handler for them updates the stored id the moment the upgrade happens, not at the next failed send.

**aiogram 3.** `Message` has both fields[8]:

```python
from aiogram import F, Router
from aiogram.types import Message

router = Router()


@router.message(F.migrate_to_chat_id)
async def on_migrate(message: Message) -> None:
    await save_chat_id(message.chat.id, message.migrate_to_chat_id)
```

**python-telegram-bot.** `filters.StatusUpdate.MIGRATE` matches these messages[12], and `Application.migrate_chat_data` moves the library's own `chat_data` from the old id to the new one; it does not change the `chat_id` of jobs already scheduled[11]:

```python
from telegram import Update
from telegram.ext import ContextTypes, MessageHandler, filters


async def on_migrate(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
    msg = update.effective_message
    if msg.migrate_to_chat_id:
        await save_chat_id(msg.chat_id, msg.migrate_to_chat_id)
        context.application.migrate_chat_data(message=msg)


app.add_handler(MessageHandler(filters.StatusUpdate.MIGRATE, on_migrate))
```

Keep the error handling from the section above as well: a bot that was offline during the upgrade, or a broadcast that reads ids from the database, still meets the old id.

## Update the stored id

If the id lives in a table, change it in one statement. Here in PostgreSQL, with the id as `BIGINT`:

```sql
UPDATE chats
SET chat_id = -1001234567890
WHERE chat_id = -123456789;
```

Do the same for every other table keyed by that chat — settings, subscriptions, scheduled posts. If the id is hard-coded in the code or set as an environment variable, change it there and redeploy; a send to the old id never starts working again.

## On Livops

- **Group ids in PostgreSQL.** Add PostgreSQL under **Databases**, and `DATABASE_URL` is written into every service in the environment, including services added later. Keep chat ids there as `BIGINT`, so the update above is one statement and survives deploys.
- **A fixed group id is a variable.** If the bot posts to one group set in a variable such as `GROUP_CHAT_ID`, change it under **Variables** to the new `-100…` id from the error. New values take effect on the next deploy; restart the service to apply them now.
- **Logs.** Log the old and the new id when you catch the migration; the project's **Logs** page and `livops logs <service> -f` show them.
- **The bot as a service.** A Telegram bot is its own service type on Livops, `bot`: always running, no public URL needed. The handlers above run in it as they do anywhere else.

A bot costs **19 credits a month** (19,000 so'm). One 500 MB database per team is free; see [Pricing](https://livops.dev/en/docs/pricing).

## Questions

**Why did my group become a supergroup?**

Someone upgraded it, often without meaning to. Telegram's apps are told to migrate a basic group to a supergroup automatically when an admin uses a feature only supergroups have. To your bot, the supergroup is a new chat with a new id.

**Where do I get the new chat id?**

From the error itself. The failed response carries parameters.migrate_to_chat_id, the id of the new supergroup. aiogram puts it on TelegramMigrateToChat.migrate_to_chat_id, python-telegram-bot on ChatMigrated.new_chat_id, and grammY and Telegraf on the error's parameters.

**Can I keep sending to the old group id?**

No. All new messages have to go to the new supergroup. The old id answers every send with this error, so replace it everywhere you stored it, including variables and scheduled jobs.

**How do I tell a supergroup id from a basic group id?**

By its range. A basic group id is between -999999999999 and -1. A supergroup or channel id is minus one trillion minus its internal id, so it is below -1000000000000. Chat.type also says group or supergroup.

**Will my bot notice the upgrade before a send fails?**

Yes, if it listens for it. A service message with migrate_to_chat_id arrives in the old group, and every bot receives service messages whatever its privacy mode. Update the stored id there, and keep catching the error for sends that still use the old id.

**Is this the same as chat not found?**

No. Chat not found means this bot does not know the id at all. This error means the id is a real group that was upgraded, and the response tells you the new id to use instead.

## Sources

1. [Telegram Bot API — Making requests, ResponseParameters, Message, Chat](https://core.telegram.org/bots/api). Checked 2 December 2026.
2. [Telegram Bot API server source — telegram-bot-api/Client.cpp](https://raw.githubusercontent.com/tdlib/telegram-bot-api/master/telegram-bot-api/Client.cpp). Checked 2 December 2026.
3. [Telegram — Channels, supergroups, gigagroups and basic groups (Migration)](https://core.telegram.org/api/channel). Checked 2 December 2026.
4. [Telegram — Bot API dialog IDs](https://core.telegram.org/api/bots/ids). Checked 2 December 2026.
5. [Telegram — Bots FAQ (what messages will my bot get)](https://core.telegram.org/bots/faq). Checked 2 December 2026.
6. [aiogram source — aiogram/exceptions.py](https://raw.githubusercontent.com/aiogram/aiogram/dev-3.x/aiogram/exceptions.py). Checked 2 December 2026.
7. [aiogram source — aiogram/client/session/base.py](https://raw.githubusercontent.com/aiogram/aiogram/dev-3.x/aiogram/client/session/base.py). Checked 2 December 2026.
8. [aiogram source — aiogram/types/message.py](https://raw.githubusercontent.com/aiogram/aiogram/dev-3.x/aiogram/types/message.py). Checked 2 December 2026.
9. [python-telegram-bot source — telegram/error.py](https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/src/telegram/error.py). Checked 2 December 2026.
10. [python-telegram-bot source — telegram/request/_baserequest.py](https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/src/telegram/request/_baserequest.py). Checked 2 December 2026.
11. [python-telegram-bot source — telegram/ext/_application.py](https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/src/telegram/ext/_application.py). Checked 2 December 2026.
12. [python-telegram-bot source — telegram/ext/filters.py](https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/src/telegram/ext/filters.py). Checked 2 December 2026.
13. [grammY source — src/core/error.ts](https://raw.githubusercontent.com/grammyjs/grammY/main/src/core/error.ts). Checked 2 December 2026.
14. [Telegraf source — src/core/network/error.ts](https://raw.githubusercontent.com/telegraf/telegraf/v4/src/core/network/error.ts). Checked 2 December 2026.
