6 guides — exact flags, auth details, and workflow notes.
Guide
TikTok Guide
This is the routing guide for the TikTok provider. Read this first when the user wants to work with TikTok Ads. Then load only the specific reference file linked below.
Load only the reference file you need. Do not preload all of them.
Pagination
TikTok uses page-number pagination (not cursor-based like Meta):
Flag
What it does
--page <n>
Page number (1-indexed)
--page-size <n>
Items per page
--all
Auto-follow all pages
--max-items <n>
Stop after N items
Common Mistakes
Forgetting TIKTOK_ADS_ACCESS_TOKEN before running API commands
Not passing --advertiser-id and not setting TIKTOK_ADS_DEFAULT_ADVERTISER_ID
Using --cursor (that's Meta) instead of --page (TikTok)
TikTok tokens expire every 24 hours — use agent-ads tiktok auth refresh to rotate
Not providing --app-id / --app-secret for advertisers list (the OAuth endpoint requires them)
Guide
TikTok Auth, Config & Output
TikTok uses the custom Access-Token HTTP header (not Bearer, not query param).
First command
TikTok Auth, Config & Output
bash
# Option 1: Store app credentials plus access tokenagent-adstiktokauthset--full# Prompts for app ID, app secret, access token, then optional refresh token# Option 2: Store both access and refresh tokensagent-adstiktokauthset--refresh-token# Prompts for access token, then refresh token# Option 3: Pipe from stdinecho"$TOKEN"|agent-adstiktokauthset--stdin# Option 3b: Pipe both access + refresh tokens from stdinprintf'%s\n%s\n'"$ACCESS_TOKEN""$REFRESH_TOKEN"|\agent-adstiktokauthset--stdin--refresh-token# Option 3c: Pipe app ID, app secret, access token, and optional refresh tokenprintf'%s\n%s\n%s\n%s\n'"$APP_ID""$APP_SECRET""$ACCESS_TOKEN""$REFRESH_TOKEN"|\agent-adstiktokauthset--stdin--full# Option 4: Shell env (CI / ephemeral)exportTIKTOK_ADS_ACCESS_TOKEN=your_token_here
Authentication
TikTok uses the custom Access-Token HTTP header (not Bearer, not query param).
Token lifecycle
Access tokens expire every 24 hours
Refresh tokens expire after 1 year
Use agent-ads tiktok auth refresh to rotate tokens automatically
Setting up auth
bash
# Option 1: Store app credentials plus access tokenagent-adstiktokauthset--full# Prompts for app ID, app secret, access token, then optional refresh token# Option 2: Store both access and refresh tokensagent-adstiktokauthset--refresh-token# Prompts for access token, then refresh token# Option 3: Pipe from stdinecho"$TOKEN"|agent-adstiktokauthset--stdin# Option 3b: Pipe both access + refresh tokens from stdinprintf'%s\n%s\n'"$ACCESS_TOKEN""$REFRESH_TOKEN"|\agent-adstiktokauthset--stdin--refresh-token# Option 3c: Pipe app ID, app secret, access token, and optional refresh tokenprintf'%s\n%s\n%s\n%s\n'"$APP_ID""$APP_SECRET""$ACCESS_TOKEN""$REFRESH_TOKEN"|\agent-adstiktokauthset--stdin--full# Option 4: Shell env (CI / ephemeral)exportTIKTOK_ADS_ACCESS_TOKEN=your_token_here
Token refresh
bash
# Refresh using stored refresh token + app credentialsagent-adstiktokauthrefresh\--app-idYOUR_APP_ID\--app-secretYOUR_APP_SECRET# Or use env varsexportTIKTOK_ADS_APP_ID=your_app_idexportTIKTOK_ADS_APP_SECRET=your_app_secretexportTIKTOK_ADS_REFRESH_TOKEN=your_refresh_tokenagent-adstiktokauthrefresh
auth refresh resolves app ID, app secret, and refresh token from CLI flags first, then shell env, then the OS credential store.
This stores the new access token (and updated refresh token) in the OS credential store.
Auth commands
Command
What it does
agent-ads tiktok auth set
Store access token
agent-ads tiktok auth set --refresh-token
Store both tokens
agent-ads tiktok auth set --full
Store app credentials plus access token, with optional refresh token
The CLI strips this envelope and returns only the data field by default. Use --envelope to see metadata.
Guide
TikTok Accounts & Objects
Requires app credentials (the OAuth endpoint needs them):
First command
TikTok Accounts & Objects
bash
agent-adstiktokadvertiserslist\--app-idYOUR_APP_ID\--app-secretYOUR_APP_SECRET# Or with env varsexportTIKTOK_ADS_APP_ID=...exportTIKTOK_ADS_APP_SECRET=...agent-adstiktokadvertiserslist
Advertisers
List authorized advertisers
Requires app credentials (the OAuth endpoint needs them):
bash
agent-adstiktokadvertiserslist\--app-idYOUR_APP_ID\--app-secretYOUR_APP_SECRET# Or with env varsexportTIKTOK_ADS_APP_ID=...exportTIKTOK_ADS_APP_SECRET=...agent-adstiktokadvertiserslist
Get advertiser details
bash
agent-adstiktokadvertisersinfo\--advertiser-id1234567890,9876543210# With custom fieldsagent-adstiktokadvertisersinfo\--advertiser-id1234567890\--fieldsdisplay_name,company,status
Campaigns
bash
# List campaigns for an advertiseragent-adstiktokcampaignslist--advertiser-id1234567890# With fields and paginationagent-adstiktokcampaignslist\--advertiser-id1234567890\--fieldscampaign_id,campaign_name,budget,status\--page-size50# Auto-paginate allagent-adstiktokcampaignslist\--advertiser-id1234567890\--all# With filteringagent-adstiktokcampaignslist\--advertiser-id1234567890\--filter'{"primary_status":"STATUS_ENABLE"}'
Ad Groups
bash
# List ad groupsagent-adstiktokadgroupslist--advertiser-id1234567890# With filtering by campaignagent-adstiktokadgroupslist\--advertiser-id1234567890\--filter'{"campaign_ids":["123456"]}'
Ads
bash
# List adsagent-adstiktokadslist--advertiser-id1234567890# With fieldsagent-adstiktokadslist\--advertiser-id1234567890\--fieldsad_id,ad_name,adgroup_id,status
Common Patterns
Default advertiser ID
Set TIKTOK_ADS_DEFAULT_ADVERTISER_ID or add default_advertiser_id to providers.tiktok in your config file to avoid repeating --advertiser-id on every command.
Filtering
TikTok filtering is a JSON object passed via --filter:
bash
# By status--filter'{"primary_status":"STATUS_ENABLE"}'# By IDs--filter'{"campaign_ids":["123","456"]}'# From a file--filter-filefilters.json
Pagination
TikTok uses page-number pagination:
bash
# Page 2, 50 items per page--page2--page-size50# Auto-paginate everything--all# Stop after 100 items--all--max-items100
Guide
TikTok Reports & Insights
Use agent-ads tiktok insights query for on-demand reporting via the /report/integrated/get/ endpoint.
# Daily campaign spend for the last weekagent-adstiktokinsightsquery\--advertiser-id123\--report-typeBASIC\--data-levelAUCTION_CAMPAIGN\--dimensionsstat_time_day,campaign_id\--metricsspend,impressions,clicks\--start-date2026-03-11--end-date2026-03-18# Lifetime metricsagent-adstiktokinsightsquery\--advertiser-id123\--report-typeBASIC\--data-levelAUCTION_AD\--dimensionsad_id\--metricsspend,impressions,conversion\--query-lifetime# Export to CSVagent-adstiktokinsightsquery\--advertiser-id123\--report-typeBASIC\--data-levelAUCTION_CAMPAIGN\--dimensionsstat_time_day\--metricsspend,impressions\--start-date2026-03-01--end-date2026-03-15\--formatcsv--outputreport.csv
The async report returns a download URL in the response data. Use curl or wget to fetch the file.
Guide
TikTok Creative Assets & Tracking
First command
TikTok Creative Assets & Tracking
bash
# List all video assetsagent-adstiktokcreativesvideos--advertiser-id1234567890# With paginationagent-adstiktokcreativesvideos\--advertiser-id1234567890\--page-size20--all# With filteringagent-adstiktokcreativesvideos\--advertiser-id1234567890\--filter'{"material_ids":["video123"]}'
Creative Assets
Search videos
bash
# List all video assetsagent-adstiktokcreativesvideos--advertiser-id1234567890# With paginationagent-adstiktokcreativesvideos\--advertiser-id1234567890\--page-size20--all# With filteringagent-adstiktokcreativesvideos\--advertiser-id1234567890\--filter'{"material_ids":["video123"]}'
Get image info
bash
# Get info for specific imagesagent-adstiktokcreativesimages\--advertiser-id1234567890\--image-idimg123,img456
agent-adstiktokaudienceslist--advertiser-id1234567890# With paginationagent-adstiktokaudienceslist\--advertiser-id1234567890\--page-size50--all
Guide
TikTok Workflows
End-to-end recipes for TikTok Ads. Each workflow is a sequence of commands you can run in order.
First command
TikTok Workflows
bash
# Step 1: List your advertisers (requires app credentials)agent-adstiktokadvertiserslist\--app-id$TIKTOK_ADS_APP_ID\--app-secret$TIKTOK_ADS_APP_SECRET# Step 2: Get details for a specific advertiseragent-adstiktokadvertisersinfo--advertiser-id1234567890# Step 3: List campaignsagent-adstiktokcampaignslist--advertiser-id1234567890
1. Account Discovery
Start from your token and discover all advertisers:
bash
# Step 1: List your advertisers (requires app credentials)agent-adstiktokadvertiserslist\--app-id$TIKTOK_ADS_APP_ID\--app-secret$TIKTOK_ADS_APP_SECRET# Step 2: Get details for a specific advertiseragent-adstiktokadvertisersinfo--advertiser-id1234567890# Step 3: List campaignsagent-adstiktokcampaignslist--advertiser-id1234567890
2. Daily Performance Report
Pull daily campaign performance for a date range, exported as CSV:
# Step 1: Submit the async taskagent-adstiktokreport-runssubmit\--advertiser-id1234567890\--report-typeBASIC\--data-levelAUCTION_AD\--dimensionsstat_time_day,ad_id\--metricsspend,impressions,clicks\--start-date2026-01-01\--end-date2026-03-01# Step 2: Check status (note the task_id from step 1)agent-adstiktokreport-runsstatus\--advertiser-id1234567890\--task-idTASK_ID_HERE# Step 3: When complete, the status response contains a download URL.# Use curl or wget to fetch the file.
5. Creative and Tracking Audit
Inspect creative assets and tracking setup:
bash
# Step 1: List video creativesagent-adstiktokcreativesvideos--advertiser-id1234567890--all# Step 2: Check pixelsagent-adstiktokpixelslist--advertiser-id1234567890# Step 3: List custom audiencesagent-adstiktokaudienceslist--advertiser-id1234567890--all
6. CI / Automation Pattern
bash
#!/bin/bashset-euopipefail# Refresh token (TikTok tokens expire every 24 hours)agent-adstiktokauthrefresh\--app-id"$TIKTOK_ADS_APP_ID"\--app-secret"$TIKTOK_ADS_APP_SECRET"# Verify setupagent-adstiktokdoctor--api-q# Pull reportagent-adstiktokinsightsquery\--advertiser-id1234567890\--report-typeBASIC\--data-levelAUCTION_CAMPAIGN\--dimensionsstat_time_day,campaign_id\--metricsspend,impressions,clicks\--start-date"$(date -d yesterday +%Y-%m-%d)"\--end-date"$(date +%Y-%m-%d)"\--formatcsv\--output/data/tiktok-yesterday.csvecho"Report saved to /data/tiktok-yesterday.csv"
Exit codes make it safe in set -e scripts: 0 = success, 1 = transport/internal, 2 = config/argument, 4 = TikTok API error.
7. Piping and Composing
bash
# Pretty-print to lessagent-adstiktokcampaignslist--advertiser-id1234567890--pretty|less# Filter with jqagent-adstiktokcampaignslist--advertiser-id1234567890--all\|jq'.[] | select(.primary_status == "STATUS_ENABLE")'# JSONL for line-by-line processingagent-adstiktokinsightsquery\--advertiser-id1234567890\--report-typeBASIC\--data-levelAUCTION_CAMPAIGN\--dimensionscampaign_id\--metricsspend,impressions\--start-date2026-03-01--end-date2026-03-16\--formatjsonl|whileIFS=read-rline;doecho"$line"|jq-r'.dimensions.campaign_id + ": $" + .metrics.spend'done