Skip to content

sendPhoto ​

Send a photo to a specified chat. Supports uploading a file directly or passing a file_id of a previously uploaded file.

Request ​

POST /:token/sendPhoto

Use multipart/form-data encoding for file uploads.

Parameters ​

ParameterTypeRequiredDescription
chat_idInteger/StringYesUnique identifier or username of the target chat
photoString/FileYesPhoto file or file_id of a previously uploaded file, max 10MB
captionStringNoPhoto 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": 101,
    "from": {
      "id": 123456789,
      "is_bot": true,
      "first_name": "MyBot",
      "username": "my_bot"
    },
    "chat": {
      "id": 987654321,
      "first_name": "User",
      "username": "user123",
      "type": "private"
    },
    "date": 1700000000,
    "photo": [
      {
        "file_id": "AgACAgIAAxkBAAI...",
        "file_unique_id": "AQADAgAT...",
        "file_size": 12345,
        "width": 320,
        "height": 240
      },
      {
        "file_id": "AgACAgIAAxkBAAI...",
        "file_unique_id": "AQADAgAT...",
        "file_size": 56789,
        "width": 800,
        "height": 600
      }
    ],
    "caption": "This is a sample photo"
  }
}

Error Codes ​

CodeDescription
400Bad request parameters, e.g. unsupported file format or exceeds size limit (max 10MB)
401Invalid or expired token
403Bot does not have permission to send messages to this chat
404Chat not found
413File too large
500Internal server error

Examples ​

Send Photo via File Upload ​

bash
curl -X POST "https://api.example.com/<token>/sendPhoto" \
  -F "chat_id=987654321" \
  -F "photo=@/path/to/image.jpg" \
  -F "caption=This is a sample photo"

Send Photo via file_id ​

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