Skip to main content
Access Media endpoints via client.media() (MediaClient).

Methods

addPostToAmplifyPrograms

POST /2/media/amplify/posts Add Post to Amplify Programs Publishes one of the authenticated user’s video posts into one or more active Amplify pre-roll programs the user is enrolled in as a publisher.

Parameters

Schemas.AddPostToAmplifyProgramsRequest
required
Request payload.
Returns: Schemas.AddPostToAmplifyProgramsResponse

addToLibrary

POST /2/media/library Add Media to Library Adds previously uploaded media to the authenticated user’s Media Library with its library metadata. The user must own the media. Geo restrictions, content expiry, the preview image and the audience policy are set with the Media metadata endpoint.

Parameters

Schemas.AddMediaToLibraryRequest
required
Request payload.
Returns: Schemas.AddMediaToLibraryResponse

appendUpload

POST /2/media/upload/{id}/append Append Media Upload Appends one segment of the file to a chunked upload. Send the segment base64-encoded in media (raw bytes in multipart bodies) and its position in the file in segment_index, counting from 0. A segment can be up to 8 MB; in a JSON body keep it to 4 MB or less, because base64 adds a third. After the last segment, call Finalize Media Upload.

Parameters

String
required
The upload id from Initialize Media Upload.
Schemas.AppendMediaUploadRequest
required
Request payload.
Returns: Schemas.AppendMediaUploadResponse

createMetadata

POST /2/media/metadata Create Media Metadata Creates metadata for a Media file.

Parameters

Schemas.CreateMediaMetadataRequest
required
Request payload.
Returns: Schemas.CreateMediaMetadataResponse

createSubtitles

POST /2/media/subtitles Create Media Subtitles Creates subtitles for a specific Media file.

Parameters

Schemas.CreateMediaSubtitlesRequest
required
Request payload.
Returns: Schemas.CreateMediaSubtitlesResponse

deleteSubtitles

DELETE /2/media/subtitles Delete Media Subtitles Deletes subtitles for a specific Media file.

Parameters

Schemas.DeleteMediaSubtitlesRequest
required
Request payload.
Returns: Schemas.DeleteMediaSubtitlesResponse

finalizeUpload

POST /2/media/upload/{id}/finalize Finalize Media Upload Completes a chunked upload once every segment is appended. For video the result carries processing_info: the media can go on a Post only when its state is succeeded, so call Get Media Upload Status until it is. A result without processing_info is ready to use.

Parameters

String
required
The upload id from Initialize Media Upload.
Returns: Schemas.FinalizeMediaUploadResponse

getAmplifyProgram

GET /2/media/amplify/programs/{program_id} Get Amplify Program Returns one Amplify pre-roll program the authenticated user is enrolled in as a publisher. A program the user is not enrolled in is reported as not found.

Parameters

String
required
Identifier of the program.
Returns: Schemas.GetAmplifyProgramResponse

getAmplifyProgramPosts

GET /2/media/amplify/programs/{program_id}/posts Get Amplify Program Posts Returns the posts published into an Amplify pre-roll program the authenticated user is enrolled in as a publisher.

Parameters

String
required
Identifier of the program.
Returns: Schemas.GetAmplifyProgramPostsResponse

getAmplifyPrograms

GET /2/media/amplify/programs Get Amplify Programs Returns the Amplify pre-roll programs the authenticated user is enrolled in as a publisher.
Returns: Schemas.GetAmplifyProgramsResponse

getAnalytics

GET /2/media/analytics Get Media Analytics Retrieves analytics data for media.

Parameters

List<String>
required
media_keys (query parameter).
String
required
start_time (query parameter).
String
required
end_time (query parameter).
Returns: Schemas.GetMediaAnalyticsResponse

getByKey

GET /2/media/{media_key} Get Media by Media Key Retrieves details of a specific Media file by its media key.

Parameters

String
required
media_key (path parameter).
Returns: Schemas.GetMediaByMediaKeyResponse

getByKeys

GET /2/media Get Media by Media Keys Retrieves details of Media files by their media keys.

Parameters

List<String>
required
media_keys (query parameter).
Returns: Schemas.GetMediaByMediaKeysResponse

getLibraryCategories

GET /2/media/library/categories Get Media Library Categories Returns the video categories a publisher can assign to a media library item and the advertiser categories whose ads can be blocked from running against it.

Parameters

Returns: Schemas.GetMediaLibraryCategoriesResponse

getUploadStatus

GET /2/media/upload Get Media Upload Status Returns how far X has processed an uploaded media file, in processing_info.state: pending, in_progress, succeeded or failed. Call it after Finalize Media Upload returns processing_info, waiting check_after_secs between calls, until the state is succeeded. A failed state means the media can’t be used.

Parameters

String
required
The media id from Initialize Media Upload.
Returns: Schemas.GetMediaUploadStatusResponse

initializeUpload

POST /2/media/upload/initialize Initialize Media Upload Starts a chunked media upload and returns its id. Use it for video and for other files too large for one request. For a video on a Post, set media_category to tweet_video, media_type to the file’s type (for example video/mp4) and total_bytes to the file’s size. Send the file with Append Media Upload, call Finalize Media Upload, then pass the id in media.media_ids on Create or Edit Post.

Parameters

Schemas.InitializeMediaUploadRequest
required
Request payload.
Returns: Schemas.InitializeMediaUploadResponse

removeFromLibrary

DELETE /2/media/library/{media_key} Remove Media Library Item Removes an item from the authenticated user’s Media Library. Posts scheduled through the API that have not yet been published and still use the media are cancelled. Published posts and the underlying media are not affected.

Parameters

String
required
The media key of the library item to remove.
Schemas.RemoveMediaFromLibraryRequest
required
Request payload.
Returns: Schemas.RemoveMediaFromLibraryResponse

updateInLibrary

PUT /2/media/library/{media_key} Update Media Library Item Updates the library metadata of an item in the authenticated user’s Media Library. Only the fields sent are changed; the others keep their values. Geo restrictions, content expiry, the preview image and the audience policy are set with the Media metadata endpoint.

Parameters

String
required
The media key of the library item to update.
Schemas.UpdateMediaInLibraryRequest
required
Request payload.
Returns: Schemas.UpdateMediaInLibraryResponse

upload

POST /2/media/upload Upload Media Uploads a media file in one request and returns its id. Send the file base64-encoded in media (raw bytes in multipart bodies). For a Post, set media_category to tweet_image (JPG, PNG, GIF or WEBP, up to 5 MB) or tweet_gif, then pass the returned id in media.media_ids on Create or Edit Post. DM media uses dm_image or dm_gif. For video, use Initialize Media Upload.

Parameters

Schemas.MediaUploadRequest
required
Request payload.
Returns: Schemas.MediaUploadResponse