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. 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.

post/2/media/upload

Request

  • Base URL
    https://api.x.com
  • URL
    https://api.x.com/2/media/upload
  • Auth
    • OAuth 2
      Authorization code: https://api.x.com/2/oauth2/authorize
      Token URL: https://api.x.com/2/oauth2/token scopes: media.write
    • or HTTP oauth

Request body

additional_ownersstring

Comma-separated list of user IDs who can use this media.

media_category'tweet_image' | 'tweet_video' | 'tweet_gif' | 'dm_image' | 'dm_video' | 'dm_gif' | 'subtitles' required

The category of the media being uploaded.

Response

The request has succeeded.

Changes

    • breaking

      added to the response body oneOf list for the response status

    • breaking

      added to the / response property oneOf list for the response status

    • info

      added https://api.x.com/2/problems/dm-bad-attachment https://api.x.com/2/problems/dm-bad-cta https://api.x.com/2/problems/dm-bad-custom-profile https://api.x.com/2/problems/dm-bad-media https://api.x.com/2/problems/dm-bad-quick-reply https://api.x.com/2/problems/dm-bad-url https://api.x.com/2/problems/dm-conversation-name-too-long https://api.x.com/2/problems/dm-conversation-not-found https://api.x.com/2/problems/dm-duplicate https://api.x.com/2/problems/dm-inactive-device https://api.x.com/2/problems/dm-not-delivered https://api.x.com/2/problems/dm-not-found https://api.x.com/2/problems/dm-not-owner https://api.x.com/2/problems/dm-participant-not-added https://api.x.com/2/problems/dm-participant-not-found https://api.x.com/2/problems/dm-participant-restricted https://api.x.com/2/problems/dm-participant-unavailable https://api.x.com/2/problems/dm-rate-limited https://api.x.com/2/problems/dm-recipient-blocks-sender https://api.x.com/2/problems/dm-recipient-cannot-receive https://api.x.com/2/problems/dm-recipient-encrypted-unavailable https://api.x.com/2/problems/dm-recipient-not-accepting https://api.x.com/2/problems/dm-recipient-not-found https://api.x.com/2/problems/dm-recipient-restricts-groups https://api.x.com/2/problems/dm-recipient-unavailable https://api.x.com/2/problems/dm-request-in-progress https://api.x.com/2/problems/dm-safety-limited https://api.x.com/2/problems/dm-safety-rejected https://api.x.com/2/problems/dm-sender-blocks-recipient https://api.x.com/2/problems/dm-sender-declined-dms https://api.x.com/2/problems/dm-sender-dms-closed https://api.x.com/2/problems/dm-sender-encrypted-unavailable https://api.x.com/2/problems/dm-sender-not-in-conversation https://api.x.com/2/problems/dm-sender-not-permitted https://api.x.com/2/problems/dm-sender-not-verified https://api.x.com/2/problems/dm-sender-phone-required https://api.x.com/2/problems/dm-sender-read-only https://api.x.com/2/problems/dm-sender-unavailable https://api.x.com/2/problems/dm-text-empty https://api.x.com/2/problems/dm-text-too-long https://api.x.com/2/problems/dm-too-few-participants https://api.x.com/2/problems/dm-too-many-participants https://api.x.com/2/problems/dm-unsupported-message mapping keys to the response discriminator for the response status

    • info

      added https://api.x.com/2/problems/dm-bad-attachment https://api.x.com/2/problems/dm-bad-cta https://api.x.com/2/problems/dm-bad-custom-profile https://api.x.com/2/problems/dm-bad-media https://api.x.com/2/problems/dm-bad-quick-reply https://api.x.com/2/problems/dm-bad-url https://api.x.com/2/problems/dm-conversation-name-too-long https://api.x.com/2/problems/dm-conversation-not-found https://api.x.com/2/problems/dm-duplicate https://api.x.com/2/problems/dm-inactive-device https://api.x.com/2/problems/dm-not-delivered https://api.x.com/2/problems/dm-not-found https://api.x.com/2/problems/dm-not-owner https://api.x.com/2/problems/dm-participant-not-added https://api.x.com/2/problems/dm-participant-not-found https://api.x.com/2/problems/dm-participant-restricted https://api.x.com/2/problems/dm-participant-unavailable https://api.x.com/2/problems/dm-rate-limited https://api.x.com/2/problems/dm-recipient-blocks-sender https://api.x.com/2/problems/dm-recipient-cannot-receive https://api.x.com/2/problems/dm-recipient-encrypted-unavailable https://api.x.com/2/problems/dm-recipient-not-accepting https://api.x.com/2/problems/dm-recipient-not-found https://api.x.com/2/problems/dm-recipient-restricts-groups https://api.x.com/2/problems/dm-recipient-unavailable https://api.x.com/2/problems/dm-request-in-progress https://api.x.com/2/problems/dm-safety-limited https://api.x.com/2/problems/dm-safety-rejected https://api.x.com/2/problems/dm-sender-blocks-recipient https://api.x.com/2/problems/dm-sender-declined-dms https://api.x.com/2/problems/dm-sender-dms-closed https://api.x.com/2/problems/dm-sender-encrypted-unavailable https://api.x.com/2/problems/dm-sender-not-in-conversation https://api.x.com/2/problems/dm-sender-not-permitted https://api.x.com/2/problems/dm-sender-not-verified https://api.x.com/2/problems/dm-sender-phone-required https://api.x.com/2/problems/dm-sender-read-only https://api.x.com/2/problems/dm-sender-unavailable https://api.x.com/2/problems/dm-text-empty https://api.x.com/2/problems/dm-text-too-long https://api.x.com/2/problems/dm-too-few-participants https://api.x.com/2/problems/dm-too-many-participants https://api.x.com/2/problems/dm-unsupported-message discriminator mapping keys to the / response property for the response status

    • breaking

      added to the response body oneOf list for the response status

    • breaking

      added to the / response property oneOf list for the response status

    • info

      added https://api.twitter.com/2/problems/duplicate-rules https://api.twitter.com/2/problems/invalid-rules https://api.x.com/2/problems/recipient-not-messageable mapping keys to the response discriminator for the response status

    • info

      added https://api.twitter.com/2/problems/duplicate-rules https://api.twitter.com/2/problems/invalid-rules https://api.x.com/2/problems/recipient-not-messageable discriminator mapping keys to the / response property for the response status