Media IDS - how long are they valid - and under what conditions?


So we use POST media/upload

We get back a valid media ID from the API

We follow this up with a statuses/update and pass the returned media ID …

What I just described works.

But, when we get the media ID back, we store it with the tweet in that user’s data base… the next time we go to tweet this again (it is a scheduled tweet that say goes out once a day)… we do not upload the same image again… we see there is a media ID in our record so we just do the

statuses/update and pass the media ID we got yesterday … this does not work - it just posts the text and the photo is missing

Why is this?

I know it says photos are available for 60 minutes if not attached to a tweet… what does it mean “not attached to a tweet”? Isn’t statuses/update and passing the media ID attaching that photo to that tweet???

Not understanding why the second day the photo is missing…

anyone have any thoughts?


The media ID is ephemeral - it exists so that the image can be attached to a Tweet, but once this has happened you would need to upload the image a second time and generate a new media ID. You cannot re-use the media ID once it has been attached to a Tweet.


OK, thanks. But I know we’ve been able to reuse media id’s for some time now.

We’ve adjusted our code to “always” upload the image. Seems like it is a bit of a waste of resources to have to load the same image if that image is going to be included in many of the users tweets (like a logo image, book cover they authored, etc.)…

Just saying…


Just to be clear (for my understanding), was this with the media/upload endpoint? have you always been able to do this previously with an unlimited (60 min+) time period?


That is correct.

Another question that I have, are these photos (that are repeated time after time) all stored under the user’s account?

We thought the purpose of the media ID’s was to eliminate redundancy.

In any event, I’m nearly certain that the ID’s we got from media/upload lived for days - if not longer.