When uploading media—images, GIFs, or videos—please remember to use the additional_owners parameter when the media will be used by a user other than the authenticated user. This applies to when media will be used in:
or when the media will be associated with an ads account using:
The additional_owners parameter is accepted in both the POST media/upload and POST media/upload (INIT) endpoints.
First, some context. I’m authenticated as 2417045708 and have access to the following ads account: 18ce54d4x5t .
$ twurl -H ads-api.twitter.com "/2/accounts/18ce54d4x5t/authenticated_user_access"
{
"data": {
"user_id": 2417045708,
"permissions": [
"ACCOUNT_ADMIN",
"TWEET_COMPOSER"
]
},
"request": {
"params": {
"account_id": "18ce54d4x5t"
}
}
}
18ce54d4x5t's FULL promotable user—that is, the user who owns the ads account—is 756201191646691328.
$ twurl -H ads-api.twitter.com "/2/accounts/18ce54d4x5t/promotable_users"
{
"request": {
"params": {
"account_id": "18ce54d4x5t"
}
},
"next_cursor": null,
"data": [
{
"user_id": "756201191646691328",
"id": "l310s",
"account_id": "18ce54d4x5t",
"created_at": "2016-07-21T22:42:09Z",
"updated_at": "2016-07-21T22:42:09Z",
"deleted": false,
"promotable_user_type": "FULL"
}
]
}
When media is uploaded, it is owned by the authenticated user by default; 2417045708, in my case.
$ twurl -H upload.twitter.com -X POST "/1.1/media/upload.json" --file coffee.jpeg --file-field "media"
{
"media_id": 908567755120508928,
"media_id_string": "908567755120508928",
"size": 1374071,
"expires_after_secs": 86400,
"image": {
"image_type": "image/jpeg",
"w": 4998,
"h": 2617
}
}
As a result, the following Tweet create request fails given that I have not added 756201191646691328 as an additional owner.
$ twurl -H ads-api.twitter.com -X POST "/2/accounts/18ce54d4x5t/tweet?text=coffee&as_user_id=756201191646691328&media_ids=908567755120508928&trim_user=true"
{
"errors": [
{
"code": "INVALID_MEDIA",
"message": "Invalid media ids"
}
],
"request": {
"params": {
"as_user_id": 756201191646691328,
"text": "coffee",
"account_id": "18ce54d4x5t",
"media_ids": [
908567755120508928
],
"trim_user": true
}
}
}
To resolve this, upload the image using additional_owners=756201191646691328:
$ twurl -H upload.twitter.com -X POST "/1.1/media/upload.json?additional_owners=756201191646691328" --file coffee.jpeg --file-field "media"
{
"media_id": 908573900237180928,
"media_id_string": "908573900237180928",
"size": 1374071,
"expires_after_secs": 86400,
"image": {
"image_type": "image/jpeg",
"w": 4998,
"h": 2617
}
}
Tweet create is successful.
$ twurl -H ads-api.twitter.com -X POST "/2/accounts/18ce54d4x5t/tweet?text=coffee&as_user_id=756201191646691328&media_ids=908573900237180928&trim_user=true"
{
"data": {
"created_at": "Fri Sep 15 06:11:27 +0000 2017",
"id": 908573962631766017,
"id_str": "908573962631766017",
"text": "coffee https://t.co/4tcPU9XUon",
"truncated": false,
"entities": {
"hashtags": [],
"symbols": [],
"user_mentions": [],
"urls": [],
"media": [
{
"id": 908573900237180928,
"id_str": "908573900237180928",
"indices": [
7,
30
],
"media_url": "http://pbs.twimg.com/media/DJvnJf_UEAAXnzC.jpg",
"media_url_https": "https://pbs.twimg.com/media/DJvnJf_UEAAXnzC.jpg",
"url": "https://t.co/4tcPU9XUon",
"display_url": "pic.twitter.com/4tcPU9XUon",
"expanded_url": "https://twitter.com/apimctestface/status/908573962631766017/photo/1",
"type": "photo",
"sizes": {
"thumb": {
"w": 150,
"h": 150,
"resize": "crop"
},
"large": {
"w": 2048,
"h": 1072,
"resize": "fit"
},
"small": {
"w": 680,
"h": 356,
"resize": "fit"
},
"medium": {
"w": 1200,
"h": 628,
"resize": "fit"
}
}
}
]
},
"source": "<a href=\"https://ads-api.twitter.com\" rel=\"nofollow\">Ads API Internal Test App</a>",
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"in_reply_to_screen_name": null,
"user": {
"id": 756201191646691328,
"id_str": "756201191646691328"
},
"geo": null,
"coordinates": null,
"place": null,
"contributors": null,
"retweet_count": 0,
"favorite_count": 0,
"favorited": false,
"retweeted": false,
"possibly_sensitive": false,
"scopes": {
"followers": false
},
"lang": "en"
},
"request": {
"params": {
"as_user_id": 756201191646691328,
"text": "coffee",
"account_id": "18ce54d4x5t",
"media_ids": [
908573900237180928
],
"trim_user": true
}
}
}
Recall that this applies to Tweets and cards as well as associating media with ads accounts.