Telegram→X Media Size Limits: Official Caps and a Staging Pipeline
A Telegram-to-X scheduling bot fails in production when an image, GIF or video exceeds the X API’s size or format rules, or when the bot cannot even download the file from Telegram. On the official Bot API (checked 2026-11-20), getFile can download files only up to 20 MB. X documents a 5 MB cap for images (JPG, PNG, GIF or WEBP), 15 MB for animated GIFs, and Post-video caps of 20 minutes / 8 GB for a default account or 125 minutes / 16 GB for an X Premium or verified account. This guide, for tools discussed on Auto X, records those official caps, walks through two worked files, and shows how to stage, normalize and isolate media failures so one bad attachment does not silently kill the text job.
What are the official Telegram and X media size limits?
The cloud Telegram Bot API lets a bot download a file of up to 20 MB through getFile, and the download link stays valid for at least one hour. X separately caps images at 5 MB, animated GIFs at 15 MB, and Post videos at 8 GB (20 minutes) or 16 GB (125 minutes) depending on the posting user’s Premium or verified status, not your developer API plan. Those two APIs do not share a ceiling, which is why a file that arrived in Telegram can still be illegal to attach to a Post.
The table below compiles the official figures checked on 2026-11-20. Telegram send limits matter when your bot sends media back to a chat; the X column is what the publish worker must meet.
| Constraint | Telegram Bot API (cloud) | Local Bot API server | X API for Posts |
|---|---|---|---|
Download with getFile | 20 MB; link valid at least 1 hour | No download size limit | — |
| Bot upload via HTTP URL | Photos 5 MB; other types 20 MB | — | — |
| Bot upload via multipart | Photos 10 MB; other files 50 MB | Uploads up to 2000 MB | — |
| Image | — | — | 5 MB; JPG, PNG, GIF or WEBP |
| Animated GIF | sendAnimation up to 50 MB | Uploads up to 2000 MB | 15 MB; also ≤1280×1080, ≤350 frames, ≤300 million pixels |
| Video | sendVideo up to 50 MB | Uploads up to 2000 MB | Default: 20 minutes / 8 GB. Premium or verified: 125 minutes / 16 GB. Minimum duration 0.5 seconds |
| Attachments per Post | — | — | Up to 4 photos, or 1 animated GIF, or 1 video |
| Chunk size (X v2) | — | — | Keep segments at or below 5 MB; server maximum 8 MB |
X also says upload and posting are separately enforced: a file can finalize successfully and still be rejected when you attach its media_id to POST /2/tweets. Video duration and size follow the posting user’s entitlement and the media_category used at initialize (tweet_video or amplify_video for a Post; a DM category is a common reason attach then fails). For Auto X’s operator steps with a photo or video, see how to schedule an X post with a photo or video from Telegram.
Worked example: an 8 MB JPEG and a 35 MB video
An 8 MB JPEG can be downloaded from Telegram and still fail on X, because the image cap is 5 MB. A 35 MB video cannot be downloaded with cloud getFile at all, even though X would usually accept that file size for a Post video. Run those two checks in the media stage before the publish worker sees the file.
File A — 8 MB JPEG, received in the bot chat. The Bot API’s getFile limit is 20 MB, so the download is allowed. Record the size, MIME type and dimensions on the job, then compare them with X’s 5 MB image cap. This file is over that cap, so the normalize step must resize or recompress it to 5 MB or less, in JPG, PNG, GIF or WEBP, before any X upload call. If it is still over 5 MB after one honest remux, mark a hard media failure and tell the operator why, rather than sending a file X will reject.
File B — 35 MB MP4, received in the bot chat. Cloud getFile will not prepare a file over 20 MB for download. The official options are to run a Local Bot API server, which can download files without a size limit and upload up to 2000 MB, or to have the user paste a link the worker can fetch from another source. Once you have the bytes, X’s default Post-video cap is 20 minutes and 8 GB (125 minutes and 16 GB for Premium or verified), so 35 MB is not the usual X size problem. Check duration (at least 0.5 seconds), aspect ratio between 1:3 and 3:1, YUV 4:2:0, and AAC-LC audio, then upload with the chunked flow: initialize, append segments of 5 MB or less, finalize, and poll status. A successful finalize is not permission to attach the media_id; handle a 403 of the form “This user is not allowed to post a video longer than N minutes.”
A 12 MB animated GIF sits between those cases: getFile can fetch it, and 12 MB is under X’s 15 MB GIF cap, but Post create can still reject it if resolution exceeds 1280×1080, frames exceed 350, or width × height × frames exceeds 300 million pixels. X says to use chunked upload with media_category=tweet_gif so large GIFs can be processed asynchronously.
Treat media as its own pipeline stage
Text validation and media validation are different jobs: a caption can be within Telegram’s 1024-character cap while the binary is still too large, the wrong codec, or impossible to download. If the worker treats “media missing or invalid” as a generic publish failure, operators retry the wrong step. Auto X can also create an AI image post for X from Telegram when there is no attachment to reuse.
Give the media stage three outcomes — success, retryable failure, or hard failure — and pass only a stable publish-ready reference into the X upload step. Token and approval design affects which failures you even see; pair this with Telegram↔X approval gates and API token hygiene. Captions have their own Bot API length cap; see how the 4096 and 1024 Telegram limits differ.
Stage outside the worker, then use chunked upload
Do not download a multi-megabyte video into short-lived function memory and upload it to X in the same request. Fetch into durable staging keyed by job id, write a publish-ready object beside the original, and pass only that reference to X. For every video, X requires the v2 chunked endpoints: POST /2/media/upload/initialize, POST /2/media/upload/{id}/append, POST /2/media/upload/{id}/finalize, then GET /2/media/upload while processing_info is present. Keep each append segment at or below 5 MB (the server maximum is 8 MB). Do not send the old command=INIT style parameters to POST /2/media/upload.
Staging also makes retries cheaper: if text publish fails after a media upload, reuse the media_id when the API still accepts it, instead of re-fetching from Telegram after the one-hour getFile link has expired.
Isolate media failures from text publish
Split the outcome so operators can see which stage broke. A Telegram download timeout or a brief X 5xx is retryable; an unsupported type after one remux, or a file still over the official cap, is a hard failure that should park for a human. If media is fine and create-post fails, keep the staged reference and apply normal publish retries without downloading from Telegram again unless the object expired.
A useful operator message looks like “JPEG still 8 MB after recompress; X image cap is 5 MB,” not “publish error.” Quiet hours and approval gates still apply when a job is requeued after a media fix.
FAQ
How large a file can a bot download from Telegram?
The cloud Bot API’s getFile method prepares files up to 20 MB, and the download link is valid for at least one hour. A Local Bot API server can download files without a size limit. Check the size field before you queue the job so the user learns about the 20 MB cloud cap in the chat, not at publish time.
What are X’s official image, GIF and video size limits?
X documents a 5 MB limit for images in JPG, PNG, GIF or WEBP and 15 MB for animated GIFs. Post video is capped at 20 minutes and 8 GB for a default account, or 125 minutes and 16 GB for an X Premium or verified account. A single Post can carry up to four photos, one animated GIF or one video. These figures were checked on the X media docs on 2026-11-20.
When should I use chunked upload?
X says to use chunked upload for all videos. The v2 flow has four steps: initialize to get a media_id, append each chunk, finalize, then poll status while processing runs. X says to keep chunks at or below 5 MB, with 8 MB as the server maximum. Use media_category=tweet_gif when you upload a larger animated GIF.
Can a media upload succeed and the post still fail?
Yes. X says upload and posting are separately enforced, so a finalized media_id can still be rejected on POST /2/tweets, including a 403 when the video is longer than the posting user is allowed to attach. Record the media stage and the post stage separately so the upload is not repeated for nothing.
Sources
- Telegram Bot API reference (getFile 20 MB, send limits, Local Bot API 2000 MB; checked 2026-11-20)
- X API: media upload introduction and size limits (checked 2026-11-20)
- X API: chunked media upload (checked 2026-11-20)
- X API: media best practices (GIF constraints and video specs; checked 2026-11-20)
Educational product ops guidance. Telegram Bot API file limits and X media upload size, format, and endpoint rules change by product and over time; re-verify on official documentation before production use. Last verified 2026-11-20.