Creating a Conversation Card with the Twitter Ads API, Twurl, and PyCharm


Required Parameters:

  • account_id
  • first_cta
  • first_cta_tweet
  • thank_you_text
  • image_media_key

Request

twurl -X POST -H ads-api-sandbox.twitter.com "/3/accounts/gq1cip/cards/image_conversation?image_media_key=3_976107515216711680&name=image conversation card&first_cta=#LoveTwitter&first_cta_tweet=I #LoveTwitter&thank_you_text=Thanks for Tweeting&title=Do you #LoveTwitter?"


Response

{
  "data": {
    "name": "image conversation card",
    "first_cta": "#LoveTwitter",
    "image_display_height": "627",
    "image": "https://pbs.twimg.com/media/DYvUnQsU0AAAJ9r.jpg",
    "thank_you_text": "Thanks for Tweeting",
    "preview_url": null,
    "id": "2fx0",
    "account_id": "gq1cip",
    "first_cta_tweet": "I #LoveTwitter",
    "created_at": "2018-03-20T18:55:27Z",
    "image_display_width": "1200",
    "card_uri": "card://976170371454926848",
    "title": "Do you #LoveTwitter?",
    "updated_at": "2018-03-20T18:55:27Z",
    "deleted": false,
    "card_type": "IMAGE_CONVERSATION"
  },
  "request": {
    "params": {
      "name": "image conversation card",
      "first_cta": "#LoveTwitter",
      "image_display_height": "627",
      "image": "https://pbs.twimg.com/media/DYvUnQsU0AAAJ9r.jpg",
      "thank_you_text": "Thanks for Tweeting",
      "image_media_key": "3_976107515216711680",
      "account_id": "gq1cip",
      "first_cta_tweet": "I #LoveTwitter",
      "image_display_width": "1200",
      "title": "Do you #LoveTwitter?",
      "card_type": "IMAGE_CONVERSATION"
    }
  }
}


Add the DM Card to a Tweet

Request

twurl -X POST -H ads-api.twitter.com "/3/accounts/18ce54jkujt/tweet?text=Image Conversation Card w/ One CTA&card_uri=card://976170371454926848&as_user_id=878264826199502848&trim_user=true" 


Response

{
  "data": {
    "created_at": "Tue Mar 20 18:56:44 +0000 2018",
    "id": 976170696018661400,
    "id_str": "976170696018661378",
    "text": "Image Conversation Card w/ One CTA",
    "truncated": false,
    "entities": {
      "hashtags": [],
      "symbols": [],
      "user_mentions": [],
      "urls": []
    },
    "source": "<a href=\"https://twitter.com/SamSchmir\" rel=\"nofollow\">Ads API Client</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": 878264826199502800,
      "id_str": "878264826199502848"
    },
    "geo": null,
    "coordinates": null,
    "place": null,
    "contributors": null,
    "retweet_count": 0,
    "favorite_count": 0,
    "favorited": false,
    "retweeted": false,
    "possibly_sensitive": false,
    "scopes": {
      "followers": false
    },
    "card": {
      "name": "promo_image_convo",
      "url": "card://976170371454926848",
      "card_type_url": "http://card-type-url-is-deprecated.invalid",
      "binding_values": {
        "thank_you_text": {
          "type": "STRING",
          "string_value": "Thanks for Tweeting"
        },
        "card_id": {
          "type": "STRING",
          "string_value": "976170371211603969"
        },
        "cta_one": {
          "type": "STRING",
          "string_value": "#LoveTwitter"
        },
        "site": {
          "type": "USER",
          "user_value": {
            "id_str": "74594552",
            "path": []
          },
          "scribe_key": "publisher_id"
        },
        "title": {
          "type": "STRING",
          "string_value": "Do you #LoveTwitter?"
        },
        "cta_one_tweet": {
          "type": "STRING",
          "string_value": "I #LoveTwitter"
        },
        "promo_image_small": {
          "type": "IMAGE",
          "image_value": {
            "url": "https://pbs.twimg.com/media/DYvUnQsU0AAAJ9r.jpg",
            "width": 1200,
            "height": 627,
            "alt": null
          }
        },
        "promo_image": {
          "type": "IMAGE",
          "image_value": {
            "url": "https://pbs.twimg.com/media/DYvUnQsU0AAAJ9r.jpg",
            "width": 1200,
            "height": 627,
            "alt": null
          }
        },
        "promo_image_large": {
          "type": "IMAGE",
          "image_value": {
            "url": "https://pbs.twimg.com/media/DYvUnQsU0AAAJ9r.jpg",
            "width": 1200,
            "height": 627,
            "alt": null
          }
        },
        "promo_image_x_large": {
          "type": "IMAGE",
          "image_value": {
            "url": "https://pbs.twimg.com/media/DYvUnQsU0AAAJ9r.jpg",
            "width": 1200,
            "height": 627,
            "alt": null
          }
        },
        "promo_image_color": {
          "type": "IMAGE_COLOR",
          "image_color_value": {
            "palette": [
              {
                "percentage": 89.79,
                "rgb": {
                  "red": 255,
                  "green": 255,
                  "blue": 255
                }
              },
              {
                "percentage": 10.21,
                "rgb": {
                  "red": 85,
                  "green": 173,
                  "blue": 237
                }
              }
            ]
          }
        },
        "card_url": {
          "type": "STRING",
          "string_value": "https://twitter.com",
          "scribe_key": "card_url"
        }
      },
      "users": {
        "74594552": {
          "id": 74594552,
          "id_str": "74594552",
          "name": "App Store",
          "screen_name": "AppStore",
          "location": "Cupertino, CA",
          "url": "http://apple.co/AppStoreToday",
          "description": "",
          "protected": false,
          "followers_count": 4701601,
          "friends_count": 21,
          "listed_count": 24815,
          "created_at": "Tue Sep 15 23:47:10 +0000 2009",
          "favourites_count": 22,
          "utc_offset": -25200,
          "time_zone": "Pacific Time (US & Canada)",
          "geo_enabled": false,
          "verified": true,
          "statuses_count": 7868,
          "lang": "en",
          "contributors_enabled": false,
          "is_translator": false,
          "is_translation_enabled": false,
          "profile_background_color": "F0F0F0",
          "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
          "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
          "profile_background_tile": false,
          "profile_image_url": "http://pbs.twimg.com/profile_images/941404148188061696/w25-myxT_normal.jpg",
          "profile_image_url_https": "https://pbs.twimg.com/profile_images/941404148188061696/w25-myxT_normal.jpg",
          "profile_banner_url": "https://pbs.twimg.com/profile_banners/74594552/1517596832",
          "profile_link_color": "0088CC",
          "profile_sidebar_border_color": "C7C7C7",
          "profile_sidebar_fill_color": "E0E0E0",
          "profile_text_color": "333333",
          "profile_use_background_image": false,
          "has_extended_profile": false,
          "default_profile": false,
          "default_profile_image": false,
          "following": false,
          "follow_request_sent": false,
          "notifications": false,
          "translator_type": "none"
        }
      },
      "card_platform": {
        "platform": {
          "device": {
            "name": "AdsApi",
            "version": "13"
          },
          "audience": {
            "name": "production",
            "bucket": null
          }
        }
      }
    },
    "lang": "en"
  },
  "request": {
    "params": {
      "as_user_id": 878264826199502800,
      "text": "Image Conversation Card w/ One CTA",
      "account_id": "18ce54jkujt",
      "trim_user": true,
      "card_uri": "card://976170371454926848"
    }
  }
}