Skip to content

sendAudio

Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.

For sending voice messages, use the sendVoice method instead.

Parameters

business_connection_idStringOptional
Unique identifier of the business connection on behalf of which the message will be sent
chat_idIntegerStringRequired
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
message_thread_idIntegerOptional
Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only
direct_messages_topic_idIntegerOptional
Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat
audioInputFileStringRequired📎 Files
Audio file to send. Pass a file\_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files »
captionStringOptional✏️ FormattableminLen 0maxLen 1024
Audio caption, 0-1024 characters after entities parsing
parse_modeStringOptional
Mode for parsing entities in the audio caption. See formatting options for more details.
caption_entitiesMessageEntity[]Optional
A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse\_mode
durationIntegerOptional
Duration of the audio in seconds
performerStringOptional
Performer
titleStringOptional
Track name
thumbnailInputFileStringOptional📎 Files
Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass "attach://attach\name>" if the thumbnail was uploaded using multipart/form-data under attach\name>. More information on Sending Files »
disable_notificationBooleanOptional
Sends the message silently. Users will receive a notification with no sound.
protect_contentBooleanOptional
Protects the contents of the sent message from forwarding and saving
allow_paid_broadcastBooleanOptional
Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
message_effect_idStringOptional
Unique identifier of the message effect to be added to the message; for private chats only
suggested_post_parametersSuggestedPostParametersOptional
A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.
reply_parametersReplyParametersOptional
Description of the message to reply to
Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user

Returns

On success, the Message object is returned.

GramIO Usage

Send an audio file by URL from a message handler using the context shorthand:

ts
bot
.
on
("message", async (
ctx
) => {
await
ctx
.
sendAudio
(
"https://example.com/track.mp3", {
performer
: "Artist Name",
title
: "Song Title",
duration
: 210,
} ); });

Reply to the user's message with the audio using replyWithAudio:

ts
bot
.
on
("message", async (
ctx
) => {
await
ctx
.
replyWithAudio
("https://example.com/track.mp3", {
performer
: "Artist Name",
title
: "Song Title",
}); });

Upload a local MP3 file using MediaUpload.path and include a caption:

ts
bot
.
on
("message", async (
ctx
) => {
await
ctx
.
sendAudio
(await
MediaUpload
.
path
("./music/track.mp3"), {
caption
:
format
`${
bold
("Now playing:")} My Favorite Track`,
performer
: "My Band",
title
: "My Favorite Track",
duration
: 195,
}); });

Resend a previously uploaded audio using its file_id for efficiency:

ts
bot
.
on
("message", async (
ctx
) => {
// file_id obtained from a previously received Message const
fileId
= "CQACAgIAAxkBAAIB...";
await
ctx
.
sendAudio
(
fileId
, {
caption
: "Resent from cache — no re-upload needed!",
}); });

Direct API call with bot.api.sendAudio (useful outside message handlers):

ts
const 
msg
= await
bot
.
api
.
sendAudio
({
chat_id
: 123456789,
audio
: await
MediaUpload
.
url
("https://example.com/track.mp3"),
performer
: "Artist",
title
: "Track",
duration
: 210,
caption
: "Enjoy the music!",
});

Errors

CodeErrorCause
400Bad Request: chat not foundThe chat_id is invalid, the bot has never interacted with the user, or the chat does not exist.
400Bad Request: wrong file identifier/HTTP URL specifiedThe file_id is malformed or the URL is unreachable / returns a non-audio response.
400Bad Request: failed to get HTTP URL contentTelegram could not download the audio from the provided HTTP URL. Ensure the URL is publicly accessible.
400Bad Request: file is too bigThe audio exceeds the 50 MB server-side limit. Compress or split the file before uploading.
400Bad Request: AUDIO_INVALIDThe file format is not supported. Only .mp3 and .m4a formats are displayed in the music player.
403Forbidden: bot was blocked by the userThe user blocked the bot. Remove them from your active user list.
429Too Many Requests: retry after NFlood control triggered. Back off for the specified number of seconds.

TIP

Use GramIO's auto-retry plugin to handle 429 errors automatically.

Tips & Gotchas

  • Only MP3 and M4A show in the music player. Other formats (OGG, WAV, FLAC) will be sent as documents. If you need voice-note playback, use sendVoice instead.
  • Use file_id to re-send. Once uploaded, store the file_id from the returned Message.audio.file_id and pass it directly on future sends — no bandwidth cost.
  • performer and title populate the mini player. Provide both to give users a proper music-player experience. Without them, Telegram displays the filename.
  • Thumbnail is only applied to fresh uploads. Passing a thumbnail with a file_id audio has no effect — Telegram uses the cached thumbnail.
  • 50 MB is the current cap. Split long recordings or reduce bitrate (128 kbps is sufficient for voice/speech).
  • Caption limit is 1024 characters. Unlike sendMessage, audio captions are capped at 1024 chars.

See Also