Introducing Livops 2.0! Promo codeCEOgives you 8,000 so‘m on your balance.What’s new

Bad Request: CHAT_SEND_WEBPAGE_FORBIDDEN — Telegram bot error and how to fix it

Bad Request: CHAT_SEND_WEBPAGE_FORBIDDEN means Telegram refused a message because it would put a link preview into a chat where your bot is not allowed to add web page previews. Turn the preview off with link_preview_options and is_disabled, send the text yourself instead of forwarding it, or make the bot an administrator of the group.

By Livops team, the people who build and run LivopsUpdated

The error, as the Telegram Bot API returns it:

{"ok":false,"error_code":400,"description":"Bad Request: CHAT_SEND_WEBPAGE_FORBIDDEN"}

Each library wraps it in its own words:

Library What you see
aiogram 3 TelegramBadRequest: Telegram server says - Bad Request: CHAT_SEND_WEBPAGE_FORBIDDEN[11][12]
python-telegram-bot telegram.error.BadRequest: Chat_send_webpage_forbidden[14][15]

python-telegram-bot removes the Bad Request: prefix and capitalizes what is left, which turns the code into Chat_send_webpage_forbidden[14]; compare in lower case.

This page explains what the error means and why it arrives as an all-capitals code, where it comes from, and the four fixes — turn the preview off, send the text instead of forwarding it, give the bot the right, or check before you send — in aiogram 3 and python-telegram-bot. It ends with the rest of the CHAT_SEND_*_FORBIDDEN family and how to find the failing send on Livops.

What does the error mean?

Telegram’s error database describes CHAT_SEND_WEBPAGE_FORBIDDEN in one line: “You can’t send webpage previews to this chat.”[4] Your bot sent something that would carry a link preview — the card with a page’s title and picture under a link — into a chat where the bot may not add previews.

The rule behind it is a chat permission. In Telegram’s API it is embed_links, which, when it is set in a group’s banned rights, “does not allow a user to embed links in the messages”[6]. TDLib maps it to its own can_add_link_previews[8], and the Bot API shows the same permission as can_add_web_page_previews: true if the user is allowed to add web page previews to their messages[7][1]. When it is off for your bot, a message with a preview is refused.

The text and the link are not the problem. The same message with the preview turned off goes through.

Why it is Bad Request in capitals

Telegram’s servers answer with error code 403 and the type CHAT_SEND_WEBPAGE_FORBIDDEN[4]; an error type is a string of capital letters, digits and underscores[3]. The Bot API server treats a 403 whose message is such a raw code as a server error, answers 400 instead, and adds the Bad Request: prefix without rewriting the code into a sentence[7]. That is why the description reads like an internal constant.

Telegram says the numeric error_code may change in the future[1], so match on the description, not only on 400.

Where it shows up

Telegram’s error database lists CHAT_SEND_WEBPAGE_FORBIDDEN for one call: messages.forwardMessages[4][5], the call that forwards messages. On the Bot API that means forwardMessage and forwardMessages of a message with a link preview. It can likely come from copyMessage and copyMessages too: in TDLib’s code a copy often goes through the same server-side forward[10]. Neither forwardMessage nor copyMessage has a parameter to drop the preview[1].

The documentation does not list it for other methods. If you see it after sendMessage or an edit, the cause and the fixes below are the same: the preview is what the chat refuses.

How to fix it

sendMessage and editMessageText take link_preview_options, a LinkPreviewOptions object whose is_disabled field turns the preview off[1]. The link stays in the text and stays clickable.

{
  "chat_id": -1001234567890,
  "text": "Release notes: https://example.com/changelog",
  "link_preview_options": {"is_disabled": true}
}

aiogram 3. For one message, pass LinkPreviewOptions(is_disabled=True). For every message, set link_preview_is_disabled in DefaultBotProperties[13]:

import os

from aiogram import Bot
from aiogram.client.default import DefaultBotProperties
from aiogram.types import LinkPreviewOptions

bot = Bot(os.environ["BOT_TOKEN"], default=DefaultBotProperties(link_preview_is_disabled=True))

# or only for this one message
await bot.send_message(chat_id, text, link_preview_options=LinkPreviewOptions(is_disabled=True))

python-telegram-bot. Pass LinkPreviewOptions(is_disabled=True), or set it once in Defaults[17]:

import os

from telegram import LinkPreviewOptions
from telegram.ext import ApplicationBuilder, Defaults

no_preview = LinkPreviewOptions(is_disabled=True)
app = ApplicationBuilder().token(os.environ["BOT_TOKEN"]).defaults(Defaults(link_preview_options=no_preview)).build()

# or only for this one message
await context.bot.send_message(chat_id, text, link_preview_options=no_preview)

The old parameter. Before Bot API 7.0 (December 29, 2023) this was disable_web_page_preview=True; 7.0 replaced it with link_preview_options in sendMessage and editMessageText[2]. The Bot API server still reads disable_web_page_preview when link_preview_options is not passed[7]. python-telegram-bot still accepts it in send_message and converts it, but raises ValueError if you pass both[16], and version 22.0 removed it from Defaults[17].

2. Send the text instead of forwarding it

When the error comes from a forward or a copy, there is no preview switch to flip[1]. Catch this exact error and send the message’s text and entities yourself, with the preview off. Raise everything else.

aiogram 3. A 400 from Telegram is TelegramBadRequest, with Telegram’s description in message[11][12]:

from aiogram import Bot
from aiogram.exceptions import TelegramBadRequest
from aiogram.types import LinkPreviewOptions, Message

NO_PREVIEW = LinkPreviewOptions(is_disabled=True)


async def forward_or_resend(bot: Bot, chat_id: int, msg: Message) -> None:
    try:
        await msg.forward(chat_id)
    except TelegramBadRequest as e:
        if "CHAT_SEND_WEBPAGE_FORBIDDEN" not in e.message or not msg.text:
            raise
        await bot.send_message(chat_id, msg.text, entities=msg.entities, link_preview_options=NO_PREVIEW)

python-telegram-bot. A 400 is BadRequest[15]; its message is the capitalized form, so compare in lower case[14]:

from telegram import LinkPreviewOptions
from telegram.error import BadRequest

NO_PREVIEW = LinkPreviewOptions(is_disabled=True)


async def forward_or_resend(bot, chat_id, msg):
    try:
        await msg.forward(chat_id)
    except BadRequest as e:
        if "chat_send_webpage_forbidden" not in e.message.lower() or not msg.text:
            raise
        await bot.send_message(chat_id, msg.text, entities=msg.entities, link_preview_options=NO_PREVIEW)

The same try works around send_message: on this error, send again with link_preview_options=NO_PREVIEW. Do not retry the same request unchanged; it gets the same answer.

3. Give the bot the right

If the previews matter — a news or release bot, say — fix the chat, not the message:

  • Make the bot an administrator. ChatPermissions describes what a non-administrator user is allowed to do in a chat[1], so the group’s default permissions do not limit an administrator.
  • Or turn the permission back on. An administrator of the group can allow members to add link previews again. A bot can do it itself with setChatPermissions if it is an administrator with can_restrict_members[1] — but that changes the rule for every member, so it is a decision for the group’s owners, not for your code. Without use_independent_chat_permissions, can_add_web_page_previews also implies the text and media permissions[1].
  • Or lift a restriction on the bot. In a supergroup a member can be restricted on its own (ChatMemberRestricted), with its own can_add_web_page_previews[1].

4. Check before you send

getChat returns the group’s default member permissions in permissions[1], and getChatMember with the bot’s own id returns the bot’s status there[1]. If the bot is an administrator, previews are allowed; if it is a member and can_add_web_page_previews is false in the defaults or in its own restriction, send with the preview off.

# aiogram 3
member = await bot.get_chat_member(chat_id, bot.id)
chat = await bot.get_chat(chat_id)
if member.status == "restricted":
    previews = member.can_add_web_page_previews
elif member.status in ("administrator", "creator"):
    previews = True
else:
    previews = bool(chat.permissions and chat.permissions.can_add_web_page_previews)

Permissions change while the bot runs, so keep the try from step 2 even if you check first.

The rest of the CHAT_SEND_*_FORBIDDEN family

The same error database has one code per kind of content, all 403 on Telegram’s side[4]:

Code Telegram’s description
CHAT_SEND_PLAIN_FORBIDDEN You can’t send non-media (text) messages in this chat.
CHAT_SEND_MEDIA_FORBIDDEN You can’t send media in this chat.
CHAT_SEND_PHOTOS_FORBIDDEN You can’t send photos in this chat.
CHAT_SEND_VIDEOS_FORBIDDEN You can’t send videos in this chat.
CHAT_SEND_DOCS_FORBIDDEN You can’t send documents in this chat.
CHAT_SEND_STICKERS_FORBIDDEN You can’t send stickers in this chat.
CHAT_SEND_GIFS_FORBIDDEN You can’t send gifs in this chat.
CHAT_SEND_POLL_FORBIDDEN You can’t send polls in this chat.
CHAT_SEND_WEBPAGE_FORBIDDEN You can’t send webpage previews to this chat.

On the Bot API you rarely see most of them raw. Before a message leaves, TDLib checks the chat’s permissions for the kind of content and answers in words, such as Not enough rights to send text messages to the chat[9] — the error on not enough rights to send text messages. That check has no case for link previews[9], so this one reaches you as Telegram’s raw code.

On Livops

This error happens while the bot runs, when it forwards or sends into a particular group; a deploy does not send into that group, so it can be green while the send fails.

  • Logs. The TelegramBadRequest or BadRequest line is on the project’s Logs page, and livops logs <service> -f follows it from the terminal; see CLI. Log the chat_id next to it so you know which group to ask about.
  • A switch without a code change. If you read the preview setting from a variable, change it in the service’s Variables section: new values take effect on the next deploy, or now if you restart the service. See Variables.
  • Ship the fix with a push. Every git push to the project’s branch starts a new deploy; push the fix, and the new version replaces the old one.

A bot costs 19 credits a month (19,000 so’m); see Pricing.

Questions

What does CHAT_SEND_WEBPAGE_FORBIDDEN mean?

Telegram's own description is: you can't send webpage previews to this chat. The message would carry a link preview, and in this chat your bot is not allowed to add one. The text itself is not the problem; the preview is.

Why is it Bad Request and in capital letters?

Telegram's servers answer with a 403 and the code CHAT_SEND_WEBPAGE_FORBIDDEN. The Bot API server passes such all-capitals codes on as 400 Bad Request without rewriting them, so you see the raw code instead of a sentence.

What is the quickest fix?

Send the message with link_preview_options set to is_disabled true. The link stays in the text and stays clickable; only the preview card is gone. In aiogram and python-telegram-bot you can make that the default for every message the bot sends.

Is disable_web_page_preview still supported?

Bot API 7.0 replaced it with link_preview_options, and the current documentation no longer lists it. The Bot API server still reads it when link_preview_options is not passed, but new code should use link_preview_options.

The error comes from forwardMessage. How do I disable the preview there?

You cannot: forwardMessage and copyMessage have no link preview option. Send the message's text and entities yourself with sendMessage and is_disabled true, or ask an administrator to give the bot the right to add link previews.

Does making the bot an administrator fix it?

It should. A chat's default permissions describe what non-administrator members may do, so they do not limit an administrator. Promoting the bot is the right fix when the previews matter, for example for a news bot.

Sources

  1. Telegram Bot API — Making requests, sendMessage, forwardMessage, copyMessage, LinkPreviewOptions, ChatPermissions, ChatMemberRestricted, ChatFullInfo, getChatMember, setChatPermissions (core.telegram.org). Checked .
  2. Telegram Bot API — Changelog (Bot API 7.0) (core.telegram.org). Checked .
  3. Telegram API — Error handling (core.telegram.org). Checked .
  4. Telegram API — error database (errors.json) (core.telegram.org). Checked .
  5. Telegram API — messages.forwardMessages (core.telegram.org). Checked .
  6. Telegram API — chatBannedRights (core.telegram.org). Checked .
  7. Telegram Bot API server source — telegram-bot-api/Client.cpp (raw.githubusercontent.com). Checked .
  8. TDLib source — td/telegram/DialogParticipant.cpp (raw.githubusercontent.com). Checked .
  9. TDLib source — td/telegram/MessageContent.cpp (raw.githubusercontent.com). Checked .
  10. TDLib source — td/telegram/MessagesManager.cpp (raw.githubusercontent.com). Checked .
  11. aiogram source — aiogram/exceptions.py (raw.githubusercontent.com). Checked .
  12. aiogram source — aiogram/client/session/base.py (raw.githubusercontent.com). Checked .
  13. aiogram source — aiogram/client/default.py (raw.githubusercontent.com). Checked .
  14. python-telegram-bot source — telegram/error.py (raw.githubusercontent.com). Checked .
  15. python-telegram-bot source — telegram/request/_baserequest.py (raw.githubusercontent.com). Checked .
  16. python-telegram-bot source — telegram/_bot.py (raw.githubusercontent.com). Checked .
  17. python-telegram-bot source — telegram/ext/_defaults.py (raw.githubusercontent.com). Checked .

Put your project online today

Connect GitHub or drop a folder. No card is asked for.

Deploy your bot

Got a question? — @livops_uz