@fahad1k
for other account i.e, 18ce53x2g0e
but when we try to get the video we get error:
please guide us a proper endpoint of getting media info by media_key for other ad accounts
You need to understand the structure around Ads account and Media library.
https://ads-api.twitter.com/4/accounts/18ce54ahyak/media_library/13_1064390134789885952
This works because the media (key: 13_1064390134789885952) is indeed in the media library that is associated with Ads account id: 18ce54ahyak.
But as you noticed, this doesn’t work:
https://ads-api.twitter.com/4/accounts/18ce53x2g0e/media_library/13_1064390134789885952
because this media (key: 13_1064390134789885952) isn’t in the 18ce53x2g0e 's media library. You can’t share an asset that is already in your Ads account’s media library with other Ads account. That’s the reason you get that error.
I understand that you don’t want to upload the same video file multiple time for all your Ads accounts you want to create a campaign. In this case, we have a special parameter called additional_owners which you can specify when you upload a media file.
Additionally, it is worth calling out the additional_owners parameter. This value can be set to a list of user IDs that are allowed to use this media. For example, in order to upload a media entity to one account and then share the entity the @furni account, the additional_owners parameter can be set to 3805104374 (which corresponds to @furni).
So with our upload API (upoload.twitter.com), you could specify a list of user IDs with this additional_owners parameter like this:
twurl -X POST -H upload.twitter.com '/1.1/media/upload.json?additional_owners=1283106296' -f ./your-file-name.jpeg -F media
* 1283106296 is a user ID of @murthy_gozaik user, and assume you hit this API using @monstersjqa3 's token.
Then, you can use the media_id in the response above when you call card creation API (one of the Creatives APIs) for instance:
twurl -X POST -H ads-api.twitter.com '/4/accounts/18ce53x2g0e/tweet?text=Using media with additional owners&media_ids=${your_media_id}&trim_user=true'
* This will create a nullcasted tweet.
Please be noted that a media_id is unique and can only exist in one place (media library), so you can’t add this media to both of your media libraries, but you can attach this media asset to your Ads tweets across your Ads account as long as you specify additional_owners parameter properly AND its expires_after_secs TTL remains (as we discussed in your previous post).
Hope this helps.
Best,
Shohei