Upload
Upload media
Uploads a media file for use in posts, direct messages, or ads. The response carries the media identifiers, including the media_key used to reference the asset in later calls.
POST
Upload a media file and get back its identifiers, including a media_key. The media field carries the file content base64-encoded in JSON bodies (raw bytes in multipart bodies); media_category is tweet_image, tweet_video, or tweet_gif for posts and ads, dm_image/dm_video/dm_gif for DMs, or subtitles. For X Ads accounts, register the returned media_key via create_media_library_item to add it to the account's media library and use it in campaigns.
Simple (non-chunked) upload for images and small files. For video or any file that needs async processing, use the chunked upload flow instead (
/initialize, /{id}/append, /{id}/finalize).
Images are limited to 5 MB. Animated GIFs are limited to 15 MB. Video should not use this endpoint.
Attaching the returned media_id to POST /2/tweets applies a second size check. See size and duration limits.Authorizations
The access token received from the authorization server in the OAuth 2.0 flow.
Body
The media file to upload: base64-encoded in JSON bodies, raw bytes in multipart bodies.
The category of the media being uploaded.
Available options:
tweet_image, tweet_video, tweet_gif, dm_image, dm_video, dm_gif, subtitles Comma-separated list of user IDs who can use this media.