Tutorial

Circle Separator

TikTok Ads API - A Practical Introduction to Creating Ads

Create campaigns, ad groups and ads via the TikTok Ads API without ever needing to open with the TikTok Ads Manager.

tiktok_create_ads.webp

In this TikTok Ads API tutorial, you will learn how to:

  • Upload Video and Image Creatives to TikTok
  • Create a TikTok Campaign
  • Create an Ad Group via the TikTok Ads API
  • Create a TikTok Ad via the API

This tutorial targets marketers working with TikTok Ads who are comfortable in a somewhat technical environment. You should already have an existing TikTok App and an access token. If not, check out our first part of the series here.

If you want to work with the TikTok Ads API but do NOT want to go through technical documentation or handle authentication yourself, check out Kitchn.io.

Upload Video and Image Creatives

To make API requests, we need to use Insomnia or Postman. Or use your programming language of choice.

To start with, we will use our previously created sandbox account instead of a “real” ad account. That way, there is no way we can mess up any real data. Follow this Youtube tutorial to create your own if you don’t want to use your real ad account.

Here’s the request we need to make. First, use business-api.tiktok.com instead of sandbox-ads.tiktok.com if using a live account.

POST https://sandbox-ads.tiktok.com/open_api/1.2/file/video/ad/upload/
{
    "advertiser_id":"{{Your Account ID}}",
    "upload_type": "UPLOAD_BY_URL",
    "file_name": "{{Your Video Name}}",
    "video_url": "{{Your Video URL}}"
}

Make sure to use a unique file name, as the TikTok Ads API will throw an error otherwise.

If successful, the response should look as follows:

{
    [...]
    "data": [
        {
            "id": "v10033g50000c5tv9s3c77ufd1ob29g0"
            [...]
        }
    ]
}


Now let’s use the video_id to get more information about the video, particularly the thumbnail image we’ll need later to create our ad.

GET https://sandbox-ads.tiktok.com/open_api/1.2/file/video/ad/info/?advertiser_id=7106541027904733185&video_ids=["v10033g50000c5tv9s3c77ufd1ob29g0"]

TikTok responds with a bunch of information about the video, like height, width, etc.

{
    [...]
    "data": {
        "list": [
            {
                "id": "v10033g50000c5tv9s3c77ufd1ob29g0",
                "height": 1920,
                "width": 1080,
                [...]
                "file_name": "{{Your Video Name}}",
                "format": "mp4",
                "poster_url": "{{Link to thumbnail image}}"
            }
        ]
    }
}

We will need to use the image from the poster_url field to create an Image Creative through the TikTok Ads API.

 POST https://sandbox-ads.tiktok.com/open_api/1.2/file/image/ad/upload/
{
    "advertiser_id":"{{Your Account ID}}",
    "upload_type": "UPLOAD_BY_URL",
    "file_name": "{{Your Image Name}}",
    "image_url": "{{Link to thumbnail image}}"
}

If successful, this should return the image ID we will need lateron.

{
    [...]
    "data": {
        [...]
        "id": "ad-site-i18n-sg/202208095d0d1d72383f815646c5b090"
    }
}

Make sure to store the video id ("v10033g50000c5tv9s3c77ufd1ob29g0") and image id ("ad-site-i18n-sg/202208095d0d1d72383f815646c5b090") for later use.

Create a TikTok Campaign

Next up, let’s create a campaign. Again, we’ll use the minimum number of fields to create our campaign. For full reference, check out TikTok’s official documentation.

The TikTok Ads API supports many different use cases and has extensive documentation.

 POST https://sandbox-ads.tiktok.com/open_api/1.2/campaign/create/
{
    "advertiser_id": "{{Your Account ID}}",
    "budget_mode": "BUDGET_MODE_DAY",
    "budget": {{Your Campaign Name}},
    "objective_type": "REACH",
    "campaign_name": "{{Your Campaign Name}}"
}

As you can see above, we’re optimizing for reach with this campaign objective. Therefore, you may want to use “CONVERSIONS” or “APP_INSTALLS” instead.

Make sure to use a unique campaign name. If successful, the TikTok Ads API will respond with the newly created campaign’s id:

{
    [...]
    "data": {
        "campaign_id":1740687531023393
    }
}

Note that the campaign id is an integer, not a string.

Create an Ad Group via the TikTok Ads API

Next, use the campaign_id from above to create an ad group.

 POST https://sandbox-ads.tiktok.com/open_api/1.2/adgroup/create/
{
    "advertiser_id": "{{Your Account ID}}",
    "campaign_id": "1740687531023393",
    "adgroup_name": "{{Your Ad Group Name}}",
    "placement_type": "PLACEMENT_TYPE_NORMAL",
    "placement": ["PLACEMENT_TIKTOK"],
    "location": [ 6252001 ],
    "budget_mode": "BUDGET_MODE_DAY",
    "budget": 1000,
    "schedule_type": "SCHEDULE_START_END",
    "schedule_end_time": "2023-01-01 00:00:00",
    "schedule_start_time": "2022-08-01 00:00:00",
    "optimize_goal": "REACH",
    "pacing": "PACING_MODE_SMOOTH",
    "billing_event": "CPM",
    "bid_type": "BID_TYPE_NO_BID",
    "frequency": 2,
    "frequency_schedule": 3
}

If you previously created a CONVERSIONS or APP_INSTALLS campaign, you will not need to pass in the frequency fields, though you may have to specify other fields.

The location id 6252001 refers to the US. Find all location ids here.

Let’s note down the adgroup_id from TikTok’s response:

{
    [...]
    "data": {
        "adgroup_id":1735011541108770
    }
}

Create a TikTok Ad via the API

Now that we have uploaded a video, created a thumbnail image, and created a campaign and ad group, we are ready to finally create the ad.

First, we’ll be creating a simple video ad with a custom identity, i.e., we are not using an existing TikTok profile but instead the display_name field.

 POST https://sandbox-ads.tiktok.com/open_api/1.2/ad/create/
{
    "advertiser_id":"7106541027904733185",
    "adgroup_id": "1735011541108770",
    "creatives": [{
        "video_id": "v10033g50000c5tv9s3c77ufd1ob29g0",
        "ad_name": "{{Your Ad Name}}",
        "ad_text": "{{Your Ad Copy}}",
        "ad_format": "SINGLE_VIDEO",
        "image_ids": [
            "ad-site-i18n-sg/202208095d0d1d72383f815646c5b090"
        ],
        "display_name": "{{Your Display Name}}"
    }]
}

Et voila, we have created our first ad:

{
    [...]
    "data": {
        "need_audit": false,
        "ad_ids": [
            1735012019671058
        ]
    }
}

If you made it to the end: Well done!

To conclude, many more nuances to all the different settings can be chosen on each level. Still, hopefully, this tutorial has given you an outlook on the process and some examples to get you started.

You are well on creating all of your TikTok Ads via the API.

Next Read