Telegram sendAudio for a Sume track: URL 20 MB, upload 50 MB

Telegram can fetch a sendAudio file from a URL up to 20 MB, or accept an upload up to 50 MB. Pass the Sume artifact link first; upload only as a fallback.

4 min readSume
All posts

To send a finished Sume music track to a Telegram chat, call sendAudio with the artifact URL as the audio value. Telegram's Bot API says that a file fetched from an HTTP URL can be at most 20 MB, and that an upload by multipart form can be at most 50 MB. A Music Router track is usually audio/mpeg on media.sume.com, so check the byte size and choose the route.

The three ways to pass the file

The audio parameter accepts a file_id, an HTTP URL or a multipart upload.

Telegram sendAudio facts (Telegram Bot API, read 2026-10-05)
MethodTelegram documentsFit for a Sume track
file_idRecommended for a file that is already on TelegramUse it to resend the same track
HTTP URL20 MB maximum for files downloaded by Telegram serversFirst choice: pass the media.sume.com artifact URL
Multipart upload50 MB maximum for this methodFallback if the URL fetch fails or the file is larger
Local Bot API serverUploads up to 2000 MBOnly if you run your own server

Send by URL, keep the file_id

Start the job in the default async mode, read the audio artifact when the envelope is terminal, and send the URL. The Music Router costs a fixed $0.125 per generation and has no duration field, so most tracks are small; check anyway with a HEAD request.

import json, os, urllib.request

def send_audio(chat_id: int, url: str, title: str) -> str:
    head = urllib.request.Request(url, method="HEAD")
    size = int(urllib.request.urlopen(head, timeout=10).headers["Content-Length"])
    if size > 20 * 1024 * 1024:
        raise ValueError("over the 20 MB URL limit: upload the bytes instead")
    body = {"chat_id": chat_id, "audio": url, "title": title}
    req = urllib.request.Request(
        "https://api.telegram.org/bot%s/sendAudio" % os.environ["TELEGRAM_BOT_TOKEN"],
        data=json.dumps(body).encode(),
        headers={"Content-Type": "application/json"})
    reply = json.load(urllib.request.urlopen(req, timeout=30))
    return reply["result"]["audio"]["file_id"]

Why keep the file_id

Telegram recommends a file_id for a file that already sits on its servers. Store the id returned by the first send and reuse it for later chats; then Telegram does not download the file from Sume again. Keep the Sume job id with it so the track can be traced.

Limits

The Telegram page that I read says nothing about how long a track may be, so do not promise a duration. The URL must be reachable by Telegram's servers without your Sume API key, which is why the public artifact link is used and not a status URL. If the send fails, read the error text from the reply before you retry, and do not start a second generation just because Telegram failed; the first job is already paid and its artifact is still there.

Sources

Related posts

More in Integrations

All Integrations posts

Written by Sume