Skip to content
TGWAY
Channels & Bots STEP 68 / 99

Telegram Chat IDs: Negative Numbers and the -100 Prefix

Positive IDs are users, negative ones basic groups, -100 supergroups and channels. Handle migrate_to_chat_id, store 64-bit IDs and find your own chat_id.

  • Applies toDevelopers
  • LevelL4
  • Reading time3 min
  • Verified

The short answer

  1. 1Positive = user, negative = basic group, -100 prefix = supergroup or channel.
  2. 2When a group becomes a supergroup its ID changes; use migrate_to_chat_id.
  3. 3Store IDs as 64-bit numbers and read them from your own bot's updates.
In this article
  1. The shape of a chat_id tells you what it is
  2. Three common mistakes
  3. How to find the ID of your own chat
  4. FAQ
  5. At a glance

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 typeHow to read it
123456789Private chat with a userPositive; the same as the user's ID
-123456789Basic groupNegative; the group's number with a minus sign
-1001234567890Supergroup or channelStarts 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

  1. Add your bot to the group or channel, or for a private chat, have the user start the bot.
  2. Send one message there.
  3. In the update your bot receives, message.chat.id is 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

Summary

At a glance

Telegram Chat IDs: Negative Numbers and the -100 Prefix — at a glance illustration
  1. 1Shape

    The sign and the -100 prefix tell you the chat type.

  2. 2Migration

    An upgraded group gets a new -100 ID; the error tells you which.

  3. 3Storage

    64-bit integer or double; never drop the -100.

Share this guide

Send it to a friend who has the same question.

Telegram WhatsApp
More

Open on your phonePoint your phone camera here to open this guide.

Updated

Related articles

View all ›