IntegrationsBeginner

How to send photos, documents, and files with a Telegram bot

Upload local images and documents, or share remote URLs, through the Telegram bot API.

7 minBeginner

Text is only part of what bots can send. Telegram has dedicated endpoints for photos, documents, audio, and video. This guide covers the three ways to send a file: a public URL, a local upload, and a reused file ID.

What you need

  • A bot token and a chat ID
  • A file to send (local path or public URL)
  • curl for testing

Step 1: Send a photo from a URL

The fastest path is to hand Telegram a public image URL. Telegram fetches it for you, so there is nothing to upload.

curl "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendPhoto" \
  -d chat_id=58291043 \
  -d photo="https://picsum.photos/600" \
  -d caption="Photo by URL"

Step 2: Upload a local file

For files on your own disk, send multipart form data. With curl, the -F flag and an @ prefix upload the file directly.

zsh - upload a document
$curl "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendDocument" \
$ -F chat_id=58291043 \
$ -F document=@"./report.pdf"
{"ok":true,"result":{"document":{"file_id":"BQACAgIAAx...","file_name":"report.pdf"}}}
$
Reuse the file_id
Every successful upload returns a file_id. Pass that same id next time instead of the file path and Telegram serves the cached copy instantly, with no re-upload.

Step 3: Pick the right method

ContentMethodNotes
Image shown inlinesendPhotoCompressed by Telegram
Any file kept as-issendDocumentNo compression, keeps name
Voice or musicsendAudioShows a player
Short looping clipsendAnimationGIF or muted mp4
Telegram - file delivered
Agent
[document] report.pdf (248 KB)
Agent
Here is the report you asked for.
Size limits
Bots can send files up to 50 MB and photos up to 10 MB through the standard API. For larger files, split them or host elsewhere and send a link.

Result

You can now push images and documents from a URL, from disk, or from a cached file ID, picking the method that matches the content type.

Watch related tutorials

Tags
#telegram#media#files#bot#upload