logo
Sends an audio file to a user, group, or channel.
๐Ÿ’ก Upload the file to the nandbox media server first and use the returned media_id as the audio value. The file must be .mp3.

Request

method is "sendAudio".
Field
Type
Required
Description
chat_id
String
Yes
The target chat or user.
audio
String
Yes
The media_id returned when you uploaded the audio file.
app_id
String
Yes
The app the message belongs to.
reference
Long
Yes
Your local id for the message. Echoed back in messageAck so you can match them up.
title
String
Optional
Track title, shown in the player.
performer
String
Optional
Artist or performer, shown in the player.
caption
String
Optional
Caption shown with the audio, 0โ€“256 characters.
to_user_id
String
Optional
Target a single user inside a group or channel.
reply_to_message_id
String
Optional
Set this to send the audio as a reply to an existing message.
echo
Integer
Optional
1 returns a copy of the sent message to you. Default 0.
web_page_preview
Integer
Optional
1 disable preview ยท 2 hide the link ยท 3 instant view ยท 4 instant view without the link.
disable_notification
Boolean
Optional
Deliver silently โ€” the user gets no notification sound.
menu_ref
String
Optional
Attach an existing predefined menu, shown inline beneath the message.
inline_menu
Array of Menu
Optional
Attach a menu defined inline. Takes priority over menu_ref if both are set.
chat_settings
Integer
Optional
1 routes the message to the Bot Manager, used for admin-only communication.

Preconditions

Your API needs the right permission, and the right standing in the chat.
Requirement
Needed for
"Send Message" permission
Sending at all.
"Reply to Message" permission
Only when using reply_to_message_id.
Chat type
Your API must be
---
---
User chat
Already started by the user
Group
A member
Channel
An admin

Response

When
Method
What it tells you
Always
messageAck
The server accepted the message. Carries the new message_id and echoes your reference.
If echo = 1
message
A full copy of the message as it was sent.
User chats only
messageDelivered
The user's device received it.
User chats only
messageSeen
The user opened it.

SDKs

SDK
Call
Callback
Java
api.sendAudio(chatId, audioFileId, reference, caption, appId);
onMessagAckCallback(MessageAck msgAck)
JavaScript
api.sendAudio(chatId, audioFileId, reference, caption, appId);
onMessagAckCallback(msgAck)
Python
napi.send_audio(chat_id=chat_id, audio_file_id=audio_file_id, reference=reference, caption=caption, app_id=app_id)
on_message_ack_callback(self, msg_ack)
๐Ÿ’ก To set title and performer, build an AudioOutMessage directly and send it with the generic send โ€” the short helpers above do not take them.

Example

Request

json
{ "method": "sendAudio", "chat_id": "90089584764538542", "audio": "null9a2270d5964f64981fb1e91dd13e5941262817bdce873cf357c92adbef906b5d.mp4a", "title": "Welcome message", "performer": "Support Team", "reference": 111111135, "app_id": "90090684293000559", "echo": 1 }
java
String uploadedAudioId = MediaTransfer.uploadFile(TOKEN, filePath); api.sendAudio(chatId, uploadedAudioId, reference, caption, appId);
javascript
MediaTransfer.uploadFile(TOKEN, filePath, config.UploadServer) .then((uploadedAudioId) => { api.sendAudio(chatId, uploadedAudioId, reference, caption, appId); }) .catch((e) => console.log("Upload failed", e));
python
napi.send_audio(chat_id=chat_id, audio_file_id=uploaded_audio_id, reference=Utils.get_unique_id(), caption=caption, app_id=app_id)

Response

json
{ "method": "messageAck", "ack": { "reference": 111111135, "date": 1741967304748, "gmid": null, "message_id": "d1_TSS4QraN126219" } }
And, because echo was 1:
json
{ "method": "message", "app_id": 90090684293000559, "message": { "message_id": "d1_TSS4QraN126219", "reference": 111111135, "date": 1741967304748, "type": "audio", "audio": { "id": "null9a2270d5964f64981fb1e91dd13e5941262817bdce873cf357c92adbef906b5d.mp4a", "duration": 42057, "size": 733645 }, "chat": { "id": "90091783822039252", "name": "My First API", "type": "Bot", "terminal": "API" }, "sent_to": { "id": "90089584764538542" }, "from": { "id": "90091783822039252", "name": "My First API", "type": "Bot", "terminal": "API" } } }

Powered by Notaku