TikTok Ads
Stream TikTok ad objects, performance and audience reports, and reports you define into Streamkap, with your own TikTok developer app or Connect with TikTok.
The TikTok Ads source reads one or more TikTok ad accounts (advertisers) through TikTok API for Business: ad objects, the creative library, and reports by day, hour or lifetime, preset or defined by you. Each resource you select becomes a topic named source_<id>.tiktok_ads.<resource>. You sign in with the long-term token of your own TikTok developer app, or with Connect with TikTok through Streamkap’s app.
What Syncs
Objects
Every object is read with TikTok’s STATUS_ALL, so a deleted campaign, ad group or ad stays a row, marked by streamkap_vendor_deleted. See Deletes.
| Resource | What it holds | Key (id) |
Read |
|---|---|---|---|
advertisers |
Each ad account: name, currency, time zone, status | The advertiser ID | Hourly |
campaigns |
Campaigns of every buying type (auction, TopView, and reach-and-frequency reservation) | The campaign ID | Every poll, whole |
ad_groups |
Ad groups, with their click and view attribution windows | The ad group ID | Every poll, whole |
ads |
Ads, Smart+ creatives included (campaign_automation_type) |
The ad ID | Every poll by modification time, and whole once a day |
smart_plus_ads |
Upgraded Smart+ ads | The Smart+ ad ID | Every poll by modification time, and whole once a day |
gmv_max_campaigns |
GMV Max campaigns (TikTok Shop) | The campaign ID | Hourly |
shops |
TikTok Shop stores the account may promote | <advertiser_id>|<store_id> |
Daily |
creative_assets_images, creative_assets_videos |
The image and video libraries | <advertiser_id>|<image_id or video_id> |
Hourly |
creative_assets_music, creative_assets_portfolios |
Music and creative portfolios (CTAs) | <advertiser_id>|<id> |
Hourly |
audiences |
Custom audiences | <advertiser_id>|<audience_id> |
Hourly |
spark_ads |
TikTok posts authorized for Spark Ads | <advertiser_id>|<post id> |
Hourly |
pixels, pixel_events_statistics |
Pixels and their event counts | <advertiser_id>|<pixel_id> |
Hourly |
pixel_instant_page_events |
Instant page events by objective and optimization goal | <advertiser_id>|<objective_type>|<optimization_goal> |
Daily |
locations |
The regions TikTok targets by | <advertiser_id>|<region_id> |
Daily |
“Hourly” and “daily” assume the default 5-minute poll interval. A library object’s key carries its advertiser, since TikTok may give two ad accounts the same library ID. shops and gmv_max_campaigns need TikTok Shop, and spark_ads the Authorize TikTok Posts permission.
Report Presets
31 report presets read TikTok’s synchronous reporting endpoint, report/integrated/get, under the names other tools use. Each is a level (advertisers, campaigns, ad_groups or ad_group, ads) with a grain:
| Presets | Rows | Restated |
|---|---|---|
<level>_reports_daily |
One row per object and day | Yes |
<level>_reports_by_country_daily (campaign, ad group, ad) |
Per country and day | Yes |
<level>_reports_hourly |
Per object and hour | Yes, 7 days at most |
<level>_reports_by_country_hourly (ad group, ad) |
Per country and hour | Yes, 7 days at most |
<level>_reports_lifetime |
One row per object, lifetime totals | Read whole every poll |
<level>_audience_reports_daily |
Per gender and age, per day | Yes |
<level>_audience_reports_by_country_daily, <level>_audience_reports_by_platform_daily |
Per country, or per platform, per day | Yes |
campaigns_audience_reports_by_province_daily, ads_audience_reports_by_province_daily |
Per province, per day | Yes |
Each preset asks for spend, CPC, CPM, impressions, clicks, CTR, reach and frequency, the video and engagement counts, conversions and results below the advertiser level, app-install metrics in basic reports, and the object’s name and parent IDs at its level.
There is no audience lifetime preset: TikTok serves no lifetime totals for audience reports, so a custom AUDIENCE report needs a time dimension. See Custom Reports.
The four <level>_reports_daily presets are selected by default with advertisers, campaigns, ad_groups, ads and smart_plus_ads. Hourly, breakdown and lifetime presets multiply the rows: an hourly report sends up to 24 rows per object per day.
Add a preset offers two selections:
- Performance reporting: the five objects above and the four daily reports (the default).
- Creative library: the five objects with the image, video, music and portfolio libraries.
Reports You Define
custom_<name> reports read the dimensions and metrics you choose. See Custom Reports.
What Each Report Row Contains
| Column | What it holds |
|---|---|
id |
The Kafka key: the row’s dimensions joined with |, after the advertiser. A daily ads report row is <advertiser_id>|<ad_id>|<day>; a by-country one adds |<country_code>. A | or % inside a value is percent-escaped, so no two rows share a key. |
advertiser_id |
The ad account the row belongs to |
| The report’s dimensions | campaign_id, stat_time_day (YYYY-MM-DD, the advertiser’s own date), stat_time_hour (YYYY-MM-DDTHH), country_code and so on, as text. An hourly row also carries its stat_time_day. |
| The metrics | Under TikTok’s own names. Impressions, clicks, reach, conversions, video plays, likes, comments, shares, follows and profile visits are integers, the other preset metrics are doubles, and names and settings (such as campaign_name) are text. A metric you add in a custom report that no preset reads arrives as text. A value TikTok serves as - is null. |
advertiser_currency, advertiser_timezone |
The ad account’s currency and time zone. See Several Ad Accounts. |
Choosing How to Sign In
| Your own developer app | Connect with TikTok | |
|---|---|---|
| Who can use it | You, or the agency that runs your ad accounts, registered as a TikTok developer | Anyone who can approve the ad accounts in TikTok |
| Setup | Register, create an app, authorize the ad accounts, exchange a code (below) | Click Connect with TikTok and approve |
| Request rate | Your app’s own: Streamkap uses half of it | A share of Streamkap’s app, which every Connect source shares |
| Sandbox | Yes | No |
Use your own developer app when you or your agency can register: its rate is yours alone. Use Connect with TikTok when you cannot register, or when TikTok answers 40119 (“developer and advertisers do not belong to the same company”) because the app’s company does not own the ad accounts. See Fixing 40119.
Connect with TikTok appears on the form only where Streamkap’s TikTok app is set up for your Streamkap deployment.
Prerequisites
- One or more TikTok ad accounts and their advertiser IDs, shown under each account’s name in TikTok Ads Manager.
- For your own developer app: a TikTok For Business account with a company email address, and the right to approve the ad accounts in TikTok Business Center.
- For Connect with TikTok: a TikTok user who can approve the ad accounts.
- For
shopsandgmv_max_campaigns: ad accounts that use TikTok Shop, and the app’s GMV Max permission. Forspark_ads: the Authorize TikTok Posts permission. - Connect with TikTok uses Streamkap’s app, which has the GMV Max permission but not Authorize TikTok Posts. To sync
spark_ads, use your own developer app.
Streamkap only reads. It never changes your campaigns, ad groups, ads or account settings.
Your Own Developer App
Do this once at TikTok API for Business. TikTok reviews the developer profile and each app, a few business days each, so start early.
1. Register as a Developer
- Choose Become a Developer and fill in the profile as the company or agency that owns the ad accounts. TikTok lets an app read only ad accounts its own company owns or manages, so this choice decides what the app can read.
- Use an email address on your company’s domain, matching the company website you enter. TikTok refuses personal email addresses.
2. Create an App
- Under My Apps, create an app for Streamkap alone, so its request rate is not shared with other tools.
- Advertiser redirect URL: any HTTPS address you control, such as your company website. TikTok sends the authorization code there in step 3; nothing needs to run at it.
- Permissions: select the read permissions of what you sync. All read permissions cover every resource:
- Ad Account Information (every resource needs it), Campaigns, Ad Groups, Ads and Consolidated Report (every report).
- Image Library, Video Library, Music Library, CTA Recommendation (creative portfolios), Custom Audiences, Pixels, Authorize TikTok Posts (Spark Ads), and the TikTok Shop permissions for
shopsandgmv_max_campaigns.
- Submit the app for review. Adding permissions later is reviewed again, and the token must then be authorized again (step 3).
3. Authorize the Ad Accounts
- In My Apps, open the app and copy its Advertiser authorization URL.
- Open it signed in as a user who can approve the ad accounts, select every ad account Streamkap should read, and confirm with the code TikTok emails.
- TikTok redirects to the Advertiser redirect URL with
auth_codein the address. Copy it: it is valid for one hour and can be used once.
4. Exchange the Code for a Long-Term Token
Within the hour, exchange the auth_code with your app’s App ID and Secret (from the app’s page in My Apps):
curl -X POST "https://business-api.tiktok.com/open_api/v1.3/oauth2/access_token/" \
-H "Content-Type: application/json" \
-d '{"app_id": "<App ID>", "secret": "<Secret>", "auth_code": "<auth_code>"}'
The answer’s data.access_token is the long-term token, and data.advertiser_ids lists the ad accounts it may read. The token does not expire. It stops working when someone cancels the authorization in TikTok, or the app loses its approval. Keep the secret out of Streamkap: only the token is entered.
5. Paste It Into One Source
Paste the token into Access token of one Streamkap source, with the ad accounts it should read. Use one Streamkap source per app: two sources on one app share its rate.
Fixing 40119
TikTok answers 40119 (“developer and advertisers do not belong to the same company”) when the app’s developer profile belongs to a company that does not own the ad accounts. Any of these fixes it:
- Register as the company that owns the ad accounts, create the app there and authorize again.
- Register as the agency that manages them, with the ad accounts in the agency’s Business Center, and authorize from there.
- Switch to Connect with TikTok, which signs in through Streamkap’s app.
Connect with TikTok
- On the Auth tab, choose Connect with TikTok under Authentication and click Connect with TikTok.
- In TikTok’s window, sign in, select every ad account Streamkap should read and confirm. The form then shows Connected.
- The form fills Advertiser ID and Additional advertiser IDs with the ad accounts you approved. Remove any you do not want to read.
The token Connect obtains does not expire. If someone cancels the authorization in TikTok, the source stops naming it; click Reconnect with TikTok and save.
Shared rate. Every Connect source shares Streamkap’s TikTok app, and TikTok limits the app as a whole. Each Connect source therefore gets a share of the app’s rate, 0.5 requests a second, reserved when you save and given back when you delete, pause or stop the source or switch it to a developer app’s token. A workspace holds at most half of the shares a Streamkap deployment has, so one workspace cannot use up the rest. When the shares are taken, Connect with TikTok and the save are refused before you approve anything at TikTok: use your own developer app instead, whose rate is yours alone. A Connect source reads at its share, so a large account’s first sync is slower than with your own app.
Streamkap Setup
1. Create the Source
- Navigate to Add Connectors.
- Choose TikTok Ads.
2. Connection Settings (Auth Tab)
- Source name: A unique name for this source.
- Authentication: TikTok developer app token (the default), or Connect with TikTok.
- Access token: The long-term token from step 4. Only with a developer app’s token.
- Advertiser ID: The first ad account. It keys the source: a second source with the same first ad account in a workspace is refused.
- Additional advertiser IDs (optional): More ad accounts read with the same sign-in, into the same topics. An account added later is read from the backfill start.
- Environment (with TikTok developer app token only): Production (the default), or Sandbox. Connect with TikTok always reads production. See Sandbox.
- Sandbox time zone: Only in the sandbox.
3. Settings Tab
- Resources: The objects and reports to sync, and
custom_<name>for each custom report. - Custom reports (optional): See Custom Reports.
- Attribution window (days): How far back daily reports are re-read once a day. 28 by default, 0 to 45. See Restatement.
- Backfill start date (optional): The first day each report reads when it first syncs. Unset, reports read two years back and objects read everything. It applies to resources added later too, and changing it does not read again what already synced.
Test connection reads every ad account’s information, in batches of 100, and names an account that is not active. With Connect with TikTok, it also checks the connection approved each account and names approved accounts the source leaves out. Test access reads each selected resource with its poll’s first request, on up to 25 ad accounts, and warns when the attribution window is shorter than an ad group’s click-through window. See Test connection and Test access. Click Next.
4. Review and Create
Check the summary and click Create. One source can read several ad accounts, and the first Advertiser ID is the account it is keyed on: see One source per vendor account. Then send the topics to a destination: see Send topics to a destination.
Custom Reports
Custom reports is a JSON list of definitions. Each makes the resource custom_<name>, which you select under Resources. Every definition must be selected, and every selected custom_<name> defined.
name: Lowercase letters, digits and underscores, starting with a letter, at most 40 characters, unique.report_type:BASIC(the default) orAUDIENCE.data_level:AUCTION_ADVERTISER,AUCTION_CAMPAIGN,AUCTION_ADGROUPorAUCTION_AD.dimensions: TikTok’s dimension names, such ascampaign_id,stat_time_dayandcountry_code.- At most one ID dimension (
advertiser_id,campaign_id,adgroup_id,ad_id,ad_id_v2) and at most one time dimension. - The time dimension sets the grain:
stat_time_daydaily,stat_time_hourhourly, neither lifetime. TikTok serves lifetime reports forBASIConly. gender,age,platform,province_id,language,placement,interest_categoryand the other audience dimensions needAUDIENCE.
- At most one ID dimension (
metrics: 1 to 1,000 of TikTok’s metric names, such asspend. Streamkap reads more than 100 in several requests and joins them on the row. A metric may not be named like one of the definition’s dimensions or a column every row carries (id,advertiser_id,advertiser_currency,advertiser_timezone,stat_time_day,streamkap_changed_at). An attribute metric named like a dimension the definition does not use, such ascampaign_idon an ad-level report, is TikTok’s own column and is fine.
[
{"name": "spend_by_country", "data_level": "AUCTION_CAMPAIGN", "dimensions": ["campaign_id", "stat_time_day", "country_code"], "metrics": ["spend", "impressions", "clicks", "campaign_name"]},
{"name": "reach_by_age", "report_type": "AUDIENCE", "data_level": "AUCTION_ADVERTISER", "dimensions": ["stat_time_day", "age", "gender"], "metrics": ["spend", "reach"]}
]
Select custom_spend_by_country and custom_reach_by_age under Resources. A row is keyed by its dimensions after the advertiser: <advertiser_id>|<campaign_id>|<day>|<country_code> for the first.
A synced custom report keeps its definition: to change one, add the changed definition under a new name, select it, and deselect the old one. A definition is checked when you save, and a metric TikTok does not know fails Test access with TikTok’s message.
Behavior & Limits
Backfill
A report’s first sync reads from the Backfill start date, or two years back, in 30-day requests (one day for hourly reports), each advertiser in its own time zone. Objects read everything, whatever the date. A request whose answer would pass 5,000 rows is split into shorter windows, down to one day, and a day is read a page at a time.
Restatement
TikTok revises report rows for days afterwards, as late conversions are attributed, and corrects the previous day after 12:00 UTC. Reports poll once an hour at the default 5-minute poll interval. So every poll of a daily or hourly report reads yesterday and today, and the first poll after 12:30 UTC each day re-reads the whole Attribution window (28 days by default; 7 days at most for hourly reports).
- Only changed rows are sent again. Streamkap keeps a digest of every row of the window, so a row whose values changed is sent again under the same
id, and an unchanged row is not. - A row TikTok stops returning is deleted, on any day of the window, at any size: for example a row whose every metric fell to zero. The destination receives a delete for its
id. - A day not read whole deletes nothing until a later poll reads it whole: a day TikTok truncated or answered only in part, or one an advertiser refused.
- Set the destination to upsert on
id, and do not sum the topic: an append-only destination keeps every version of a restated row.
Set the window to at least your ad groups’ longest click-through window (28 days at most); 45 days covers SKAdNetwork postbacks. Test access warns when an ad group’s window is longer than the source’s. Lifetime reports are read whole on every poll instead: only changed rows are sent, and a row no longer served is deleted.
Deletes
- Objects: a deleted campaign, ad group or ad stays a row, since TikTok keeps reporting its spend, and its boolean column
streamkap_vendor_deletedistrue. Streamkap asks TikTok for each delete status separately, because TikTok’s list serves a deleted object like a paused one and may leavesecondary_statusout, so do not filter onsecondary_statusto find deleted objects. The column is oncampaigns,ad_groups,adsandsmart_plus_ads, and it is not a delete record: it is a value on a live row. A deleted parent flags its children too: campaigns and ad groups the poll it happens,adsandsmart_plus_adswith the daily whole read, up to a UTC day later. - Purged objects: an object TikTok removes for good is deleted (
__deleted = true) when the next whole read no longer finds it: every poll for campaigns and ad groups, the daily whole read foradsandsmart_plus_ads, the next read for the libraries. - A short or refused listing changes nothing: when TikTok answers a delete listing with fewer rows than its own count, or refuses one of the delete statuses, that ad account’s rows keep their last values and nothing is deleted that poll. If it stays short for 6 polls in a row, the rows go out flagged from the statuses TikTok did answer, and a flag set wrongly for want of the rest corrects on the next whole read.
- Reports ask for every status, so a deleted ad’s spend stays in its rows. See Restatement for rows TikTok stops serving.
A purged object or report row arrives as a record with __deleted = true. See Deletes.
Several Ad Accounts
Every resource reads all its ad accounts into the same topic, each row carrying its advertiser_id. Each ad account reports in its own currency and time zone:
advertiser_currencyandadvertiser_timezoneare on every report row. Convert to one currency before summing across ad accounts.stat_time_dayis the ad account’s own date. On a given UTC instant, an account at UTC+14 is already on the next day and one at UTC−12 still on the previous one.
An ad account that refuses a resource is skipped with a warning, and its rows already delivered stay; only when every ad account refuses does the resource stop. See Connector status.
Smart+ Campaigns
A Smart+ campaign’s creatives arrive as rows of ads, marked by campaign_automation_type. Upgraded Smart+ ads are in smart_plus_ads. A report’s ad_id joins ads.ad_id.
Large Accounts
TikTok’s reports cover at most 20,000 ads: past that, TikTok answers only the newest 20,000 ads’ rows. Streamkap then reads that ad account in batches of campaigns, then ad groups, so every ad is reported, which makes the first sync of a large account slower. A day still truncated in its smallest batch is sent as read and deletes nothing.
Sandbox
A developer app’s sandbox ad account is for testing. Choose Environment Sandbox, paste the sandbox account’s token and advertiser ID, and enter Sandbox time zone: the IANA name of the zone you chose when you created the account, such as Asia/Riyadh, since TikTok’s sandbox does not report it.
- TikTok serves the sandbox mock data dated 2020-12-08 to 2020-12-19, so set the Backfill start date before it.
- The sandbox allows 1 request a second per endpoint, so Streamkap reads it at 0.4 a second.
- Connect with TikTok has no sandbox.
- The token is saved for the environment it was entered for: switching the environment needs the other environment’s token in the same save.
Rate Limits
TikTok limits each developer app per endpoint; the Basic tier allows 10 requests a second.
- With your own developer app, Streamkap sends at most 5 requests a second, half the Basic tier, one at a time, leaving the rest to your other tools on the same app.
- With Connect with TikTok, a source sends at most its share, 0.5 a second. See Connect with TikTok.
- An ad account’s own throttle (code 40133) is waited out, and the source stays Active.
- When the app’s limit is spent (code 40100 or 40016), the source shows Throttled for TikTok’s 5-minute pause and resumes on its own. If it recurs, apply for a higher rate tier in My Apps → App Detail → Authorization.
Report reads are never sent twice: TikTok blocks a request that times out repeatedly, so a report read that fails is split into smaller reads instead.
Errors
TikTok answers almost every failure with HTTP 200 and its own code. A token TikTok no longer accepts, or 40119, stops the source until you save a fixed credential. A permission missing for one resource pauses only that resource. A temporary TikTok error is retried. See Troubleshooting.
Per-Resource Failures
A missing permission (codes 40001, 40118 and 40125) pauses only the affected resource, and its status names the permission to add under My Apps → the app → Permissions. A missing TikTok Shop or GMV Max permission pauses shops and gmv_max_campaigns the same way, and the other resources keep syncing. Add the permission, authorize the ad accounts again and paste the new token, or deselect the resource. A rejected token or 40119 stops the whole source. See Connector status.
Editing the Source
- Token: click Replace on Access token and save. For Connect with TikTok, click Reconnect with TikTok.
- Switching to Connect with TikTok needs a share of Streamkap’s app: see Connect with TikTok. Switching to a developer app’s token gives the share back.
- Environment: needs that environment’s token in the same save.
- Custom reports: see Custom Reports.
- Additional advertiser IDs: an account added syncs from the backfill start; an account removed stops syncing. Its objects and lifetime-report rows are deleted on the next whole read; the rows of its daily and hourly reports stay.
Everything else follows Editing an API source.
Troubleshooting
| Message starts | Cause | Fix |
|---|---|---|
| “TikTok rejected the access token (40105 …” and the other token codes (40102, 40104, 40106, 40113, 40124), “TikTok no longer accepts the access token …” | The token was revoked, the authorization cancelled, or the app lost its approval | Authorize the ad accounts again (step 3), exchange the new auth_code and paste the token with Replace |
| “TikTok says your developer app’s company does not own …” (40119) | The app’s developer profile belongs to another company than the ad accounts’ owner | See Fixing 40119 |
| “TikTok refused to let the access token read the ad accounts …”, “Give your developer app the read permission this resource needs …” (40001, 40118, 40125) | The app lacks the permission, or the token was authorized before it was added | Add the permission under My Apps → the app → Permissions, authorize again and paste the new token, or deselect the resource |
| “TikTok did not return ad account(s) … for this sign-in” | The ad account was not authorized for the app, or the ID is wrong | Check the IDs in TikTok Ads Manager, and authorize the account in step 3 |
| “Ad account … is …, not STATUS_ENABLE” (warning) | The ad account is disabled or under review | Resolve it in TikTok Ads Manager. Its history still syncs. |
| “TikTok no longer honours this source’s connection …”, “Reconnect this source with TikTok …” | Connect with TikTok: the authorization was cancelled | Click Reconnect with TikTok and save |
| “This connection did not authorize ad account(s) …” | Connect with TikTok: the account was not approved in TikTok’s window | Click Reconnect with TikTok and approve it, or remove it |
| “This connection also authorized ad account(s) …” (warning) | Approved accounts the source leaves out | Add them under Additional advertiser IDs to sync them |
| “TikTok says this token was not issued to Streamkap’s TikTok app …” | A developer app’s token was sent with Connect with TikTok selected | Choose TikTok developer app token, or click Connect with TikTok |
| “TikTok refused to finish connecting (40110 …” | The authorization was already used or is more than an hour old | Click Connect with TikTok again |
| “TikTok connected no ad account …” | No ad account was approved in TikTok’s window | Click Connect with TikTok again and approve at least one |
| “This workspace holds its full share of Streamkap’s TikTok app …” | The workspace’s Connect sources hold half of the app’s shares | Use your own developer app, or delete a Connect source you no longer need |
| “Streamkap’s TikTok app is at capacity on this Streamkap deployment …” | Every share of Streamkap’s app is taken | Use your own developer app, or contact Streamkap support |
| “TikTok’s request limit for the developer app is spent (40100/40016) …” | Your app’s rate limit is spent, by Streamkap or another tool on it | Nothing: the source resumes after TikTok’s pause. Use an app for Streamkap alone, or apply for a higher tier. |
| “The sandbox is the sandbox ad account of your own developer app …” | Sandbox with Connect with TikTok | Choose TikTok developer app token, or Production |
| “Sandbox time zone is required in the sandbox …”, “Sandbox time zone ‘…’ is not an IANA time zone name …” | The sandbox’s zone is missing or misspelt | Enter the zone, such as Asia/Riyadh |
| “Custom report ‘…’ …” | A definition breaks a rule in Custom Reports; the message names it | Fix the definition |
| “No custom report is defined for custom_…”, “Custom report(s) … are defined but not selected” | Custom reports and Resources disagree | Select every definition and define every selected custom_<name> |
| “Additional advertiser IDs must be numbers …”, “… list the same advertiser twice” | An ID is not digits only, or is repeated | Enter each advertiser ID once, as shown in TikTok Ads Manager |
| “TikTok answered code 40002 to report/integrated/get …” | TikTok refused a report request, such as a metric it does not serve at that level | Fix the custom report the message names, or deselect it |
Related Documentation
- API sources - how API sources work, Test access, deletes, status and sending topics to a destination
- Facebook Ads - Meta ad objects and insights reports
- Google Ads - Google Ads objects and performance reports