Scheduled Tweet: While fetching scheduled tweets, what does media_id and media_key mean?

media

#1

Hey Team,

We’re fetching scheduled tweets (https://developer.twitter.com/en/docs/ads/creatives/api-reference/scheduled-tweets) using Scheduled Tweets endpoint but not sure about the media ids and keys we receive in the API response.

We’re not sure whether media id/key points to the media library (https://developer.twitter.com/en/docs/ads/creatives/api-reference/media-library) or account media (https://developer.twitter.com/en/docs/ads/creatives/api-reference/account-media).

It will be really great if someone can explain it properly.

Thanks!


#2

This is a good question, @FivetranD.

Let’s look at an example.

$ twurl -H ads-api.twitter.com "/4/accounts/18ce54d4x5t/scheduled_tweets/919052373825224704"
{
  "request": {
    "params": {
      "scheduled_tweet_id": 919052373825224704
    }
  },
  "data": {
    "completed_at": "2017-10-14T04:10:01Z",
    "id_str": "919052373825224704",
    "text": "multiple split media key",
    "user_id": "756201191646691328",
    "scheduled_status": "SUCCESS",
    "id": 919052373825224704,
    "media_ids": [
      "908573900237180928",
      "894683646111526913"
    ],
    "nullcast": true,
    "created_at": "2017-10-14T04:08:55Z",
    "scheduled_at": "2017-10-14T04:10:00Z",
    "card_uri": null,
    "updated_at": "2017-10-14T04:10:01Z",
    "tweet_id": "919052646215950337",
    "media_keys": [
      "3_908573900237180928",
      "3_894683646111526913"
    ]
  }
}

The media ID is a numeric-only value (represented as a string in the response). Every media asset—image, GIF, or video—has one. The media key is the same thing, but has an integer and underscore prefix. In this example, 3_. When creating Scheduled Tweets, we only accept media ID values (the parameter is media_ids), but we decided to render the media key, too.

You should be able to find the asset in the Media Library by using the GET accounts/:account_id/media_library/:media_key endpoint and specifying the media key. Note that, depending on the state of the media (e.g., did it exist in the Media Library before it was added to the Scheduled Tweet), it may or may not be returned in the GET accounts/:account_id/media_library endpoint.