v1

latestOpenAPI 3.0.12026-07-17110111.4 KB

Uploads media to X (formerly Twitter) for attaching to tweets.

This function uploads a media file to X, which can then be attached to a tweet. It takes a Buffer object containing the media file and its MIME type as input. The function returns a promise that resolves to a MediaUploadResponse object containing details about the uploaded media.

post/upload

Request body

Response

Successful media upload

media_idnumber

The media ID as a number

media_id_stringstring required

The media ID as a string

sizenumber

The size of the media file in bytes

expires_after_secsnumber

The number of seconds until the uploaded media expires