The short answer
- 1Positive = user, negative = basic group, -100 prefix = supergroup or channel.
- 2When a group becomes a supergroup its ID changes; use migrate_to_chat_id.
- 3Store IDs as 64-bit numbers and read them from your own bot's updates.
In this article
The shape of a chat_id tells you what it is
A Bot API chat ID (chat_id) is a single number, but its sign and its first digits are enough to tell you what kind of chat it belongs to. The values below are examples.
| Shape (example) | Chat type | How to read it |
|---|---|---|
123456789 | Private chat with a user | Positive; the same as the user's ID |
-123456789 | Basic group | Negative; the group's number with a minus sign |
-1001234567890 | Supergroup or channel | Starts with -100 |
Inside Telegram's own protocol (MTProto), groups and channels have positive numbers of their own. The Bot API puts all of them into one number space so they never collide: basic groups get a minus sign, and supergroups and channels are shifted further down so they begin with -100. For how the three kinds of chat differ in the API, see the four Telegram APIs.
Three common mistakes
The ID changes when a group becomes a supergroup
Some changes to a basic group, such as turning on certain admin features or making it public, upgrade it to a supergroup, and it gets a new -100… ID. If your bot sends to the old ID, the error response includes the new one in migrate_to_chat_id. Update the stored value with it and send again.
{
"ok": false,
"error_code": 400,
"description": "Bad Request: group chat was upgraded to a supergroup chat",
"parameters": { "migrate_to_chat_id": -1001234567890 }
}
The group itself also receives a service message carrying the same new ID, so a bot that reads updates can update its records before it ever sends.
Storing it in a 32-bit integer
A -100… ID does not fit in 32 bits. The Bot API documentation says to store chat IDs as a signed 64-bit integer or a double-precision float. Languages that keep all numbers as floats, such as JavaScript, handle this range safely.
Dropping the -100
You can shorten an ID for display, but always send it in its original form. 1234567890 and -1001234567890 are different chats to the API.
How to find the ID of your own chat
- Add your bot to the group or channel, or for a private chat, have the user start the bot.
- Send one message there.
- In the update your bot receives,
message.chat.idis that chat's ID. How to receive updates is in webhooks vs long polling.
For a public group or channel you can put @username in place of the number. A private one only has its numeric ID.
To send a message once you have the ID, see your first Bot API requests.
FAQ
Why does my Telegram chat ID start with -100?
It is a supergroup or a channel. The Bot API shifts their IDs so they begin with -100 and never collide with users or basic groups.
Why did my group's chat ID change?
The basic group was upgraded to a supergroup and got a new -100 ID. Errors sent to the old ID include the new one in migrate_to_chat_id.
How do I get my group's chat ID?
Add your bot, send a message, and read message.chat.id from the update your bot receives.
Sources
At a glance
- 1Shape
The sign and the -100 prefix tell you the chat type.
- 2Migration
An upgraded group gets a new -100 ID; the error tells you which.
- 3Storage
64-bit integer or double; never drop the -100.
Updated