POST media/upload
Upload media (images) to Twitter for use in a Tweet or Twitter-hosted Card. For uploading videos or for chunked image uploads (useful for lower bandwidth connections), see our chunked POST media/upload endpoint.
Ensure your POST is a multipart/form-data
request. You may either upload the raw binary of the file or its base64-encoded contents. The resulting media_id
or media_id_string
will be used to pass to the POST statuses/update or Card-related API endpoints. See our uploading media guide for more on using this endpoint.
Uploaded media files will be available for use for 60 minutes before they are flushed from the servers (if not associated with a Tweet or Card). Note that you need to call the upload endpoint for each media file you want to upload, storing the media_ids
to use with other endpoints, such as POST statuses/update. We suggest using the media_id_string
value to avoid issues in Javascript and other languages that do not support 64-bit integers.
The media
and media_data
parameters are mutually exclusive.
Media uploads for images are limited to 5MB in file size, and for videos are limited to 15MB. For chunked uploads, the maximum chunk size is 5MB.
MIME-types supported by this endpoint: PNG, JPEG, BMP, WEBP, GIF, Animated GIF
Note: The domain for this endpoint is upload.twitter.com
Resource URL
https://upload.twitter.com/1.1/media/upload.json
Resource Information
Parameters
The raw binary file content being uploaded. Cannot be used with media_data
.
The base64-encoded file content being uploaded. Cannot be used with media
.
A comma-separated string of user IDs to set as additional owners who are allowed to use the returned media_id
in Tweets or Cards. A maximum of 100 additional owners may be specified.
OAuth Signature Generator
Sign in to see a list of your registered applications.
Example Request
POST
https://upload.twitter.com/1.1/media/upload.json
Example Result
{ "media_id": 553639437322563584, "media_id_string": "553639437322563584", "size": 998865, "image": { "w": 2234, "h": 1873, "image_type": "image/jpeg" } }