tiktok_ads
The TikTok Ads source reads every ad account that authorized your developer app,
along with its campaign structure, creative assets, Spark Ads posts, audiences,
pixels, pixel event statistics, and performance reports. Daily, hourly, and audience report tasks run
asynchronously and read incrementally per ad account. Synchronous window
reports cover apps without access to report tasks. It uses an
HTTP manifest
and targets TikTok API for Business version v1.3. The connector is in preview.
It has been checked against TikTok’s API docs and tested with mock responses,
but has not been tested against a live ad account.
Configuration
Create a developer app in the
TikTok API for Business portal and
have each advertiser authorize it. Exchange the authorization code for a
long-term token with
/oauth2/access_token/.
The token does not expire until it is revoked. The app ID and secret are shown
under My Apps → App Detail → Basic Information. Grant the app the permission
scopes that cover the resources you select. TikTok returns code 40001 for a
missing permission.
Connection testing lists the authorized ad accounts with the token, app ID, and
secret. Every read starts from that list.
Asynchronous reports are open only to allowlisted developer apps. Ask your
TikTok representative to enable them before you select a report task
resource. Window and lifetime reports do not need the allowlist. See
TikTok’s asynchronous report docs.
Window reports require both dates. TikTok reads them in each ad account’s time
zone and rejects a span longer than 30 days. pixel_event_statistics_window
reads the same dates in UTC with the same limit. Every other resource ignores
the dates.
Resources
The authorized ad accounts come from
GET /open_api/v1.3/oauth2/advertiser/get/.
That list is read on every run and never written. Every other resource makes
its requests once per ad account, with two exceptions. Ad-level lifetime and
window reports make them once per campaign. pixel_event_statistics_window
makes them once per pixel.
A report task resource runs one task per ad account. It creates the task with
POST /open_api/v1.3/report/task/create/,
polls
GET /open_api/v1.3/report/task/check/
every 30 seconds until the status is SUCCESS, and downloads the CSV from
GET /open_api/v1.3/report/task/download/.
Up to five ad accounts run at once.
advertisers, campaigns, ad_groups, ads, and the four lifetime reports
are selected by default. The other resources are optional. Report task
resources stay off by default because they need an allowlisted app. Window
reports stay off because they need a date window.
Campaigns, ad groups, and ads include deleted objects. Each row keeps its
advertiser ID, and IDs are globally unique, so the object ID alone is the key.
Audiences, pixels, images, videos, music, creative portfolios, and Spark Ads
posts are keyed by advertiser ID and object ID, since audiences and pixels can
be shared with several ad accounts. A Spark Ads post’s object ID is item_id.
Image, video, music, cover, and license URLs expire within hours and change on
every read. Ads carry tiktok_item_id, music_id, and card_id, which point
to the Spark Ads post, the music, and the creative portfolio they use.
music reads only music the ad account uploaded. TikTok’s music library is
shared by every account and caps paging at 100,000 tracks, so it is left out.
pixel_event_statistics_window returns one row per pixel with its event
statistics for the whole window as JSON. TikTok can list a pixel shared with an
ad account without letting that account read its statistics. TikTok then
returns an error code, which fails the read.
Basic reports group by one ID and by stat_time_day or stat_time_hour, or by
the ID alone for lifetime reports. That grouping is the key. Ad-level reports
group by ad_id, which TikTok reports at creative level for Upgraded Smart+
ads. Each level adds the names and settings TikTok returns as attribute
metrics, such as campaign_name, currency, and the app and placement fields
of ad groups and ads. Daily, lifetime, and window reports read the same 97
metrics. They cover cost, delivery, reach, conversions, results, video views,
focused views, engagement, app events, website events, TikTok Shop, and
view-through and click-through attribution. Advertiser daily reports add cash
and voucher spend, which TikTok reports only at advertiser level and not for
lifetime or hourly reports. Hourly reports read 78 of the 97. They leave out
reach, frequency, results, and the other unique-user metrics, along with the
Shop, paid focused view, and engaged-view-through metrics, which TikTok
supports only by day or for the lifetime.
The country reports for ad groups and ads add country_code to the key. They
read the 52 metrics TikTok supports with a country breakdown and no attribute
metrics. TikTok groups by country only by day, so there is no hourly country
report.
Audience reports read data by day at advertiser, campaign, ad group, or ad
level, broken down by age and gender, country, or operating system. Ad audience
reports also break down by province. Their keys add those columns to the ID and
day. Window audience reports read 32 metrics. The age and gender and province
breakdowns add reach, frequency, and cost per 1,000 reached, which TikTok
allows with those dimensions and not with operating system. Report task
audience reports read 26, since TikTok does not allow unique-user metrics with
audience dimensions in report tasks. Campaign, ad group, and ad audience
reports add the names and settings of their level, except country breakdowns,
for which TikTok lists no attribute metrics. Country breakdowns are only window
reports, because TikTok documents that report tasks return the country name in
country_code. Audience reports have no lifetime version, since TikTok does
not support lifetime metrics for them.
Metric values are strings exactly as TikTok returns them. TikTok returns -
when a metric does not apply, such as a result at campaign level, so values are
not cast to numbers. stat_time_day is the start of the day in the ad account’s
time zone.
Modes
All resources support full reads. Use full upsert to refresh existing rows, or full replace to also remove rows that TikTok no longer returns. Report task resources also support incremental upsert. Every ad account keeps its own watermark onstat_time_day, or on stat_time_hour for hourly
reports. The first run and every full read ask for all days from 2019-01-01.
Later runs start 28 days before the latest day the ad account returned, so
each task rereads the last four weeks and upserts them. The end date is fixed
at 2099-12-31 so each task runs through the current day. TikTok sets no limit
on report task dates.
The 28 days match TikTok’s longest
click attribution window.
A conversion can be credited to a click up to 28 days after it, so recent
days keep changing. TikTok also
replaces real-time data
with processed data the next day and settles unique-user and audience data
after about 16 hours. Report task data refreshes every few hours, and the
current day may be inaccurate. Days older than 28 days are not reread, so a
later correction to them needs a full read.
Entity and asset listings, lifetime reports, and window reports are full only. Campaign
and ad group listings have no modified-time filter. The ad listing has one, but
it shares one watermark across every ad account and TikTok suggests keeping it
within six months. Lifetime reports have no date. Move the date window of a
window report over recent days and upsert.
Behavior
- Auth sends the token in the
Access-Tokenheader. Listing the authorized ad accounts also sends the app ID and secret as query parameters, as TikTok requires. Report downloads use the same header. - Errors arrive as HTTP 200 responses with a nonzero
code. Codes0and20001(partial success) are read as success. Any other code fails the read with TikTok’s message, including server and maintenance codes, which are not retried. - Report task errors are reported less clearly. An error code from task
creation fails the read because the response has no task ID, without
TikTok’s message, and is not retried. An error code while polling fails the
read because the response has no status. A task that ends as
FAILEDorCANCELEDfails the read, as does a task still pending after three hours. A failed run commits no watermark, so the next run creates fresh tasks. When task creation failed, resuming that attempt stops because the creation outcome is unknown, so start a new run instead. This applies to the whole attempt when any ad account’s task creation failed. An attempt that failed only while polling or downloading keeps its task IDs and resumes those tasks. A task that ended asFAILEDorCANCELEDfails again on resume, so start a new run for that case too. - Pagination requests pages from 1 up to
page_info.total_page. Listings, music, and synchronous reports use 1,000 rows per page. Audiences, images, videos, and creative portfolios use 100. Spark Ads posts use 50 and pixels use 20. Pixel statistics are unpaged, and report tasks return one unpaged file. - Rate limiting is one request per second across the connection, which
holds report task creation to TikTok’s limit of one per second per app.
TikTok also allows 500 task creations per ad account per hour. Codes
40100and40016mark an app-level limit and back off from 30 seconds. Code40133marks an advertiser-level limit and backs off from 5 seconds. Polls honor these codes. Task creation does not. TikTok asks callers that hit a per-minute limit to wait five minutes and a daily limit to wait until midnight UTC. Filament does not track those quotas or other pipelines that share the app. - Window reports cover at most 30 days with a day breakdown and are not split into smaller requests. Backfill longer periods one window at a time. TikTok caps synchronous hourly reports at one day, so hourly data comes only from report tasks.
- Deleted objects are included in synchronous reports through a status
filter of
STATUS_ALLon the campaign, ad group, or ad level. Rows under a deleted parent may still be left out by TikTok’s default filters at lower levels. Report tasks accept no status filter, so they follow TikTok’s defaults, which TikTok does not document. - Truncation applies to synchronous reports, which return at most 20,000
ads per request. Ad-level lifetime and window reports request one campaign at
a time with a
campaign_idsfilter, as TikTok recommends, at one request per campaign. TikTok documents no limit on ads per campaign, so a campaign with more than 20,000 reportable ads, deleted ads included, would still come back truncated without an error. Report tasks have no such limit and suit those accounts. - Downloads fail the read past 1 GiB per task. A first hourly read of a large ad account covers its whole history in one file and may reach that limit.
- Latency varies by metric. Reach and frequency settle after about 16 hours. Audience breakdowns lag by 10 to 16 hours depending on the dimension.
- Scope follows TikTok’s defaults. Promote campaigns made in the TikTok app and TopView ads are excluded from entity listings. Branded Mission data appears only in advertiser-level reports.