Skip to content

sendVoice ​

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

Request ​

POST /:token/sendVoice

Use multipart/form-data encoding for file uploads.

Parameters ​

ParameterTypeRequiredDescription
chat_idInteger/StringYesUnique identifier or username of the target chat
voiceString/FileYesVoice file or file_id of a previously uploaded file
captionStringNoVoice message caption text
parse_modeStringNoParsing mode for the caption, supports HTML or Markdown
durationIntegerNoDuration of the voice message in seconds
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": 103,
    "from": {
      "id": 123456789,
      "is_bot": true,
      "first_name": "MyBot",
      "username": "my_bot"
    },
    "chat": {
      "id": 987654321,
      "first_name": "User",
      "username": "user123",
      "type": "private"
    },
    "date": 1700000000,
    "voice": {
      "file_id": "AwACAgIAAxkBAAI...",
      "file_unique_id": "AQADAgAT...",
      "duration": 5,
      "mime_type": "audio/ogg",
      "file_size": 23456
    },
    "caption": "This is a voice message"
  }
}

Error Codes ​

CodeDescription
400Bad request parameters, e.g. unsupported file format
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 Voice via File Upload ​

bash
curl -X POST "https://api.example.com/<token>/sendVoice" \
  -F "chat_id=987654321" \
  -F "voice=@/path/to/voice.ogg" \
  -F "caption=This is a voice message" \
  -F "duration=5"

Send Voice via file_id ​

bash
curl -X POST "https://api.example.com/<token>/sendVoice" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 987654321,
    "voice": "AwACAgIAAxkBAAI...",
    "duration": 5
  }'