Skip to content

Instantly share code, notes, and snippets.

{
"media_id": 983472336710938600,
"media_id_string": "983472336710938624",
"size": 42572,
"expires_after_secs": 86400,
"image": {
"image_type": "image/jpeg",
"w": 1200,
"h": 627
}
example$ twurl -H upload.twitter.com "/1.1/media/upload.json" -d "command=FINALIZE&media_id=983472336710938624" | jq
example$ twurl -H upload.twitter.com "/1.1/media/upload.json" -d "command=APPEND&media_id=983472336710938624&segment_index=0" --file /Users/sam/Desktop/twitter.jpg --file-field "media" | jq
{
"media_id": 983472336710938600,
"media_id_string": "983472336710938624",
"expires_after_secs": 86399
}
// media_type can be image/jpg, image/png, image/gif or video/mp4
example$ twurl -H upload.twitter.com "/1.1/media/upload.json" -d "command=INIT&media_type=image/jpg&total_bytes=42572" | jq
{
"created_at": "Mon Apr 09 22:02:09 +0000 2018",
"id": 983465112228061200,
"id_str": "983465112228061184",
"text": "Example Image Direct Message Card with One CTA",
"truncated": false,
"entities": {
"hashtags": [],
"symbols": [],
"user_mentions": [],
example$ twurl -X POST -H api.twitter.com "/1.1/statuses/update.json?status=Example Image Direct Message Card with One CTA&card_uri=card://983445576036433920&nullcast=true" | jq
{
"data": {
"name": "example image dm card",
"first_cta": "Example CTA #1",
"first_cta_welcome_message_id": "975571635007664132",
"image_display_height": "627",
"image": "https://pbs.twimg.com/media/DaTOPm9UQAAB2LW.jpg",
"recipient_user_id": "825082408299028480",
"preview_url": null,
"id": "5kcof",
// JSON Request 👇
POST https://ads-api.twitter.com/3/accounts/YOUR_ADS_ACCOUNT_ID/cards/image_direct_message?first_cta=Example CTA #1&first_cta_welcome_message_id=865707372148174852&image_media_key=3_983137386224697344&name=example image dm card&recipient_user_id=825082408299028480
// Twurl Request 👇
example$ twurl -X POST -H ads-api.twitter.com "/3/accounts/YOUR_ADS_ACCOUNT_ID/cards/image_direct_message?name=example image dm card&first_cta=Example CTA #1&first_cta_welcome_message_id=975571635007664132&recipient_user_id=825082408299028480&image_media_key=3_983137386224697344" | jq
// JSON Request 👇
POST https://api.twitter.com/1.1/statuses/update.json?status=Hello!%20This%20Tweet%20was%20sent%20via%20the%20Twitter%20API.
// Twurl Request 👇
example$ twurl -X POST -H api.twitter.com "/1.1/statuses/update.json?status=Hello! This Tweet was sent via the Twitter API." | jq