How does managing Media Keys work?

api

#1

I keep getting the following error and I think I’m close to understanding why.

Error: One or more media keys are not managed.]
message: ‘One or more media keys are not managed.’,
code: 324

I did 3 things:

  1. I uploaded an image yesterday and, using the API, figured out its media_id

  2. When someone tweets at me, I want to tweet this image back at them with some generated text.

  3. I use statuses/update, with the parameters including status:“my text”, and my media_ids being my media_id from yesterday

I checked if media_ids update in some way, but they’re exactly the same.

It was working yesterday, but now it’s off again.

Do you know what I’m doing wrong?


#2

You cannot re-use media IDs in this way. Media uploads and IDs have a finite lifespan.


#3

Thanks so much Andy! (Great blog posts and videos, btw)

I have two follow up questions:

  1. Is the idea that media_ids is best to be used soon after I upload a media?

  2. If I do want to post this image in future tweets, can I use the media url (as in the picture)?

Thanks again!


#4

Is there any documentation specifying the lifetime of a media ID?


#5

It’s the expires_in field in the media object returned from the media/upload endpoint.


#7

FWIW I’ve never seen a media of anytime not expire after a day (86400 seconds).