Skip to content

sendDocument ​

Send a document file to a specified chat. Supports uploading a file directly or passing a file_id of a previously uploaded file. Suitable for sending files of any type, with a maximum size of 100MB.

Request ​

POST /:token/sendDocument

Use multipart/form-data encoding for file uploads.

Parameters ​

ParameterTypeRequiredDescription
chat_idInteger/StringYesUnique identifier or username of the target chat
documentString/FileYesDocument file or file_id of a previously uploaded file, max 100MB
captionStringNoDocument caption text
parse_modeStringNoParsing mode for the caption, supports HTML or Markdown
reply_markupObjectNoCustom keyboard or inline keyboard markup, JSON-serialized object
reply_to_message_idIntegerNoID of the message to reply to

Response ​

Returns the sent Message object on success.

json
{
  "ok": true,
  "result": {
    "message_id": 105,
    "from": {
      "id": 123456789,
      "is_bot": true,
      "first_name": "MyBot",
      "username": "my_bot"
    },
    "chat": {
      "id": 987654321,
      "first_name": "User",
      "username": "user123",
      "type": "private"
    },
    "date": 1700000000,
    "document": {
      "file_id": "BQACAgIAAxkBAAI...",
      "file_unique_id": "AQADAgAT...",
      "file_name": "report.pdf",
      "mime_type": "application/pdf",
      "file_size": 524288
    },
    "caption": "This is a report document"
  }
}

Error Codes ​

CodeDescription
400Bad request parameters, e.g. missing document or chat_id
401Invalid or expired token
403Bot does not have permission to send messages to this chat
404Chat not found
413File too large (exceeds 100MB)
500Internal server error

Examples ​

Send Document via File Upload ​

bash
curl -X POST "https://api.example.com/<token>/sendDocument" \
  -F "chat_id=987654321" \
  -F "document=@/path/to/report.pdf" \
  -F "caption=This is a report document"

Send Document via file_id ​

bash
curl -X POST "https://api.example.com/<token>/sendDocument" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 987654321,
    "document": "BQACAgIAAxkBAAI...",
    "caption": "Forwarding a document"
  }'