How to get a chat_id for the Telegram Bot API

A chat_id tells the Bot API where to send a message. For a private chat it's the user's ID; for groups and channels it's the chat's ID. The quickest way to get either is @userid_bot; developers can also read it from getUpdates.

The fast way

Open @userid_bot

With getUpdates

  1. Send any message to your bot (or post in the group or channel where your bot is an admin).
  2. Open this URL in a browser, with your own token:
    https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates
  3. Find "chat":{"id": ...} in the response. For channel posts look in channel_post.chat.id.

If the response is empty, send a new message and reload. If you get a "Conflict" error, your bot has a webhook set; getUpdates doesn't work while a webhook is active.

Send a test message

curl -s "https://api.telegram.org/bot<YOUR_TOKEN>/sendMessage" \
  -d chat_id=-1001234567890 \
  -d text="Hello from my bot"

chat_id formats

Chat typeExample
Private chat (user)6152847391
Basic group-412345678
Supergroup / forum-1001234567890
Channel-1001234567890 or @channelusername

Common errors

Never paste your bot token into websites or share it. Anyone with the token controls your bot.