Telegram error 400: Bad Request: chat_id is empty
Last verified against Telegram Bot API reference
Bad Request: chat_id is emptyWhat error 400 means
The request reached Telegram but the required chat_id parameter was missing, blank, or serialized as something Telegram reads as empty (for example the string "undefined" in some JavaScript stacks becomes a non-numeric value and produces a different error, whereas an actual empty string or omitted field produces this one).
Unlike chat not found, where the ID exists but does not resolve, here there is nothing to resolve. It almost always indicates a bug in how the request is assembled rather than a problem with Telegram state, and it is one of the few Bot API errors that points squarely at your own code.
The token is valid (otherwise you would see 401), and the method name is correct (otherwise 404).
What it looks like
{"ok":false,"error_code":400,"description":"Bad Request: chat_id is empty"}Why it happens
- The variable holding the chat ID was never set in this code path (for example a scheduled job that has no incoming update to read it from).
- Form encoding dropped a numeric 0 or null, sending
chat_id=. - A typo in the parameter name (
chatId,chat) so the realchat_idwas never included. - An environment variable for a broadcast channel ID is missing in the deployed environment.
How to fix Telegram error 400
- 1Dump the exact outgoing request body and check the
chat_idkey and value. - 2Assert non-empty chat_id in your send wrapper and throw before the HTTP call.
- 3For scheduled or webhook-triggered sends, load the chat ID from storage explicitly rather than from a request context that does not exist.
- 4Check environment configuration on the host that produced the error, not just locally.
How to stop it recurring
Make chat_id a required, typed argument in every internal send function so that the compiler or a runtime validator catches omission. Keep channel and admin chat IDs in configuration with startup validation that fails fast when they are absent.
A useful contrast when debugging: an empty field gives this error, an unresolvable value gives chat not found, and a valid-but-blocked target gives a 403. Seeing which of the three you get tells you whether to look at request assembly, stored data, or the recipient. The string "undefined" from JavaScript templates lands in the second bucket, not this one.
Official reference: Telegram Bot API reference. See all Telegram error codes or the Telegram limits and quotas.
Related codes
Error 400 - quick answers
What does Telegram error 400 mean?
The request reached Telegram but the required chat_id parameter was missing, blank, or serialized as something Telegram reads as empty (for example the string "undefined" in some JavaScript stacks becomes a non-numeric value and produces a different error, whereas an actual empty string or omitted field produces this one).
How do I fix Telegram error 400?
1. Dump the exact outgoing request body and check the chat_id key and value. 2. Assert non-empty chat_id in your send wrapper and throw before the HTTP call. 3. For scheduled or webhook-triggered sends, load the chat ID from storage explicitly rather than from a request context that does not exist. 4. Check environment configuration on the host that produced the error, not just locally.
Stop debugging Telegram by hand
Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.