Skip to main content
The following example assumes you have installed, configured, and authorized your app and user using twurl. twurl is a command-line tool in the spirit of cURL that gracefully handles X OAuth authentication. twurl is a great tool for quickly testing and debugging Ads API (and REST API) functionality. To see the full headers of the request and response, use -t to trace the call, roughly equivalent to cURL’s -v option. For this example, we will create a Dynamic Product Ads (DPA) campaign. Retrieve the account id.
Retrieve the funding instrument id.
Hit the GET accounts/:account_id/funding_instruments API using the account id retrieved in the previous command.

Step 1: Create campaign

Create a campaign and associate it with the funding instrument.
Specify a start time and a budget for the campaign.
  • Required fields: funding instrument, campaign name, budget (total/daily), start time, and ads account ID

Step 2: Create line item with Sales objective

Create a line item associated with the campaign.
  • Required fields: campaign id (from Step 1), product type, placements, objective, goal, entity status, primary web event tag, catalog id, product set id, creative_source, ads_account_id
  • catalog_id and product_set_id can be found in your shopping manager
  • creative_source should always be DYNAMIC_PRODUCT_CREATIVE
  • objective should always be WEBSITE_CLICKS
  • goal should always be WEBSITE_CONVERSIONS
  • After this step, the campaign will be available to see in X’s Ads Manager.

Step 3: Create DPA card

Create a DPA card.
  • Required parameters: ads account ID and URL:
  • The URL must start with https://twitter.com - any additional UTM can be appended on afterwards like in the example below:
    • https://twitter.com?utm_source=%7B%7Bsite_source%7D%7D
  • Optionally, you can choose the format of your card by specifying creative_type with one of the following values: “CAROUSEL”, “SINGLE”, “COLLECTION”. If not specified, your card will be created as a carousel card.

Step 4: Create Post

Create a post.
  • Required parameters: ads account ID, user ID, card URI (from Step 3), text, name, & dynamic product ad
  • dynamic_product_ad should always be set to true

Step 5: Associate post with line item

Associate the post with the line item.
  • Required parameters: ads account id, line item id (from Step 2) and tweet id (id_str from Step 4)
If advertisers want to see the card in the UI - it will also be available.