Blog and knowledge base of the service
Sending a document message in a Telegram bot
Published: 04.08.2025

A Telegram document message is a universal method for sending files of any format to Telegram. It is used to transfer PDF, Excel, Word, archives and other types of data that cannot be sent through specialized methods (`sendPhoto`, `SendAudio'). Telegram retains the original file quality, adds previews (for supported formats) and allows you to accompany the document with a signature with formatting. The maximum size is 2 GB, which makes the method ideal for professional data exchange.

Sending a document message in a Telegram bot

What formats does an audio message accept in Telegram and what are the limitations?

The messenger allows you to send, for example:

  1. Office documents — PDF, DOCX, XLSX and others.
  2. Electronic books.
  3. Excel spreadsheets.


Limitations

  1. The maximum file size is 2 GB (with Telegram Premium — 4 GB).
  2. The maximum length of the file name is 60 characters
  3. When adding files via the Telegram smartphone app, they are sent by default without a signature — it can be added to each file after publication. 


Popular errors when sending a document message

400 Bad Request: Wrong file identifier

- Reason: Invalid URL, broken file_id, or restricted access to the file. 

- Solution: Check the Content-Type and resource availability. 

413 Request Entity Too Large

- Reason: File >2 GB. 

- Solution: Compress the archive or split the file into parts. 

400 Bad Request: Thumbnail must be JPEG and <200 KB

- Solution: Compress the custom preview: 

400 Bad Request: Can't parse caption entities

- Reason: An error in the HTML/Markdown markup of the signature. 

- Solution: Check tag escaping. 

403 Forbidden: Bot can't send messages in chat

- Solution: Give the bot admin rights in the chat/channel. 

Information

Technical information for the BOT-MARKET API

  1. Message type code (`MessageType'): "8" (for `sendDocument'). 
  2. Max. Sending speed: 10 messages/second (due to the large file sizes).


Tips for effective use

1. File Name optimization:

  - Use Latin letters and underscores: sales_report_Q2_2024.xlsx instead of the Report for the 2nd quarter 2024.xlsx . 

2. Document previews:

  - For PDF: Telegram automatically generates previews from the first page. 

  - For other formats: create a JPEG screenshot. 

3. Security:

  - Password-lock archives with confidential data → send the password in a separate message. 

Comments
to write comments
Comment list is empty. Start now!