Media ID Life Cycle


#1

When you upload an image - the API returns a media ID. This media ID can then be used in a status update.

Does anyone know how long that media ID is valid for? Is it like 30 minutes, 30 days, or just unknown?

Reason is that we were storing media ID’s in our DB for reuse, but then found that trying to reuse them on another status update would fail and only the text portion of the update would post.

Only current work around is to upload the same file for each status update that uses the same image, which is eating up a ton of bandwidth - as well as taking time.

Anyone have some idea as to how long a media ID is valid for???

Thanks!


#2

The media IDs for uploaded media are valid for some time, I am not sure if there is a fixed timeframe. After some time, as far as I know and after some exploring, they seem to be “garbage collected”, as in deleted if not used in any tweet. If not attached to any tweet they don’t exist very long.
But even if attached to a Tweet, you don’t get any benefit of storing them beyond that point, as currently they can’t be reused, as you already observed.


#3

These details can be found on the media upload API documentation page. We should probably add it to the upload media guide! To quote the page:

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