Skip to content

sendMediaGroup ​

Send a media group (a collection of photos or videos) to a specified chat. A maximum of 10 media files can be sent per request.

Request ​

POST /:token/sendMediaGroup

Use multipart/form-data encoding for file uploads.

Parameters ​

ParameterTypeRequiredDescription
chat_idInteger/StringYesUnique identifier or username of the target chat
mediaJSON StringYesJSON string of an InputMedia object array, max 10 elements
reply_to_message_idIntegerNoID of the message to reply to

InputMedia Object ​

The media parameter is a JSON array where each element is an InputMedia object:

FieldTypeRequiredDescription
typeStringYesMedia type, e.g. photo or video
mediaStringYesfile_id of the file or reference to an uploaded file via attach://
captionStringNoMedia caption text
parse_modeStringNoParsing mode for the caption

Response ​

Returns an array of sent Message objects on success.

json
{
  "ok": true,
  "result": [
    {
      "message_id": 106,
      "from": {
        "id": 123456789,
        "is_bot": true,
        "first_name": "MyBot",
        "username": "my_bot"
      },
      "chat": {
        "id": 987654321,
        "first_name": "User",
        "username": "user123",
        "type": "private"
      },
      "date": 1700000000,
      "media_group_id": "13579246810",
      "photo": [
        {
          "file_id": "AgACAgIAAxkBAAI...",
          "file_unique_id": "AQADAgAT...",
          "file_size": 12345,
          "width": 800,
          "height": 600
        }
      ],
      "caption": "First photo"
    },
    {
      "message_id": 107,
      "from": {
        "id": 123456789,
        "is_bot": true,
        "first_name": "MyBot",
        "username": "my_bot"
      },
      "chat": {
        "id": 987654321,
        "first_name": "User",
        "username": "user123",
        "type": "private"
      },
      "date": 1700000000,
      "media_group_id": "13579246810",
      "photo": [
        {
          "file_id": "AgACAgIAAxkBAAI...",
          "file_unique_id": "AQADAgAT...",
          "file_size": 67890,
          "width": 800,
          "height": 600
        }
      ]
    }
  ]
}

Error Codes ​

CodeDescription
400Bad request parameters, e.g. invalid media format or more than 10 elements
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 Media Group via file_id ​

bash
curl -X POST "https://api.example.com/<token>/sendMediaGroup" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 987654321,
    "media": [
      {
        "type": "photo",
        "media": "AgACAgIAAxkBAAI_photo1...",
        "caption": "First photo"
      },
      {
        "type": "photo",
        "media": "AgACAgIAAxkBAAI_photo2..."
      },
      {
        "type": "photo",
        "media": "AgACAgIAAxkBAAI_photo3..."
      }
    ]
  }'

Send Media Group via File Upload ​

bash
curl -X POST "https://api.example.com/<token>/sendMediaGroup" \
  -F "chat_id=987654321" \
  -F 'media=[{"type":"photo","media":"attach://photo1","caption":"First photo"},{"type":"photo","media":"attach://photo2"}]' \
  -F "photo1=@/path/to/image1.jpg" \
  -F "photo2=@/path/to/image2.jpg"