Connect Retool to TikTok Ads using a REST API Resource pointing to the TikTok Marketing API (ads.tiktok.com/open_api). Authenticate with a long-lived access token generated from a TikTok developer app. Query campaign metrics, ad group performance, and creative analytics using the Reporting API, then build a unified paid media dashboard that compares TikTok performance alongside Meta and Google Ads data.
| Fact | Value |
|---|---|
| Tool | TikTok Ads |
| Category | Marketing |
| Method | REST API Resource |
| Difficulty | Intermediate |
| Time required | 35 minutes |
| Last updated | April 2026 |
Why connect Retool to TikTok Ads?
TikTok Ads Manager provides detailed campaign reporting, but paid social teams managing multi-platform budgets need data from TikTok alongside Meta, Google, and LinkedIn in a single view. TikTok's native reporting cannot be customized to internal KPI definitions, does not allow combining TikTok conversion data with actual revenue from a database, and makes cross-platform ROAS calculations a manual spreadsheet exercise. Retool gives media buyers and performance marketing teams a custom operations hub that queries the TikTok Marketing API alongside other ad platforms.
The most impactful use case is a unified cross-platform ad performance dashboard. TikTok's video-first creative formats produce different engagement patterns than static Meta or Google search ads — creative performance metrics like video view rate, average watch time, and thumb-stop ratio are unique to TikTok and require specific API fields. Retool lets you build dashboards that expose these TikTok-specific metrics alongside standard cross-platform metrics like CPM, CPC, and ROAS in a single Table, making creative and budget decisions more efficient.
TikTok's Marketing API uses an advertiser-centric structure: every API call requires an advertiser_id parameter. The Reporting API is the primary endpoint for performance data, accepting a list of dimensions (e.g., campaign_id, ad_id, stat_time_day) and metrics (spend, impressions, clicks, conversion, video_play_actions) to return flexible aggregations. Unlike Meta's Insights API, TikTok returns data through a synchronous reporting endpoint rather than asynchronous report jobs for standard date ranges.
Integration method
TikTok Ads connects via Retool's REST API Resource targeting the TikTok Marketing API at https://business-api.tiktok.com/open_api. Authentication uses a long-lived access token obtained through TikTok's OAuth 2.0 developer flow — stored in Retool configuration variables so it never reaches the browser. All API requests proxy through Retool's server-side infrastructure, eliminating CORS concerns. You query the Reporting API for synchronized performance metrics and the Campaign/Ad Group/Ad APIs for structural data.
Prerequisites
- A TikTok for Business account (business.tiktok.com) with an active ad account
- Access to TikTok for Developers (developers.tiktok.com) to create a Marketing API app
- The advertiser_id of the TikTok ad account you want to query (visible in TikTok Ads Manager URL)
- Admin or operator access to the TikTok ad account to authorize the developer app
- A Retool account with Resource creation permissions
Step-by-step guide
Create a TikTok Marketing API developer app and obtain an access token
To access TikTok's Marketing API, you need a developer app registered in TikTok for Developers that has been granted access to your ad account. Navigate to developers.tiktok.com and sign in with your TikTok for Business account. Click Create App in the top right. Select Marketing API as the API type. Fill in the app name (e.g., Retool Integration), app description, and your company information. Under Scopes, enable the relevant scopes: at minimum, enable Reporting (for reading campaign metrics) and Ad Management Read (for reading campaign structure). Submit the app for review — basic marketing apps are typically approved within a few business days. Once approved, the app shows a status of Active. In the app detail page, copy the App ID and App Secret. To generate an access token, TikTok uses OAuth 2.0. For server-to-server integrations, use the OAuth authorization code flow: construct an authorization URL pointing to https://ads.tiktok.com/marketing_api/auth with your app_id, redirect_uri, and state parameters. After your TikTok for Business admin completes the OAuth flow and grants access, you receive an authorization code. Exchange this code at https://business-api.tiktok.com/open_api/v1.3/oauth2/access_token/ with your app_id, secret, and auth_code to receive an access_token and refresh_token. Store the access_token and note the advertiser_id returned in the OAuth response. TikTok access tokens expire after 24 hours but refresh tokens are valid for 365 days — implement a Retool Workflow to refresh the token daily using the refresh_token endpoint.
Pro tip: For testing purposes, TikTok's sandbox environment (ads.tiktok.com/marketing_api/sandbox) allows you to generate test access tokens without completing a full OAuth flow. Use the sandbox for initial setup and switch to production credentials once the integration is working.
Expected result: You have a TikTok Marketing API access token and your advertiser_id. The token grants access to the Reporting API and Campaign read operations for your ad account.
Configure the TikTok Marketing API Resource in Retool
In Retool, navigate to the Resources tab in the left sidebar and click Add Resource. Select REST API from the list of resource types. Name the resource TikTok Marketing API. In the Base URL field, enter https://business-api.tiktok.com/open_api/v1.3 — this is the current stable API version endpoint. TikTok's Marketing API uses the version in the base URL path rather than as a parameter, so pin it here to control upgrade timing. In the Headers section, click Add Header. Set the header name to Access-Token and the value to {{ config.TIKTOK_ACCESS_TOKEN }}. This references a Retool configuration variable you will create for the access token. TikTok's Marketing API requires the Access-Token header (not the standard Authorization: Bearer format used by most APIs — this is a common source of 40001 authentication errors). To create the configuration variable: navigate to Settings → Configuration Variables in Retool. Click Add variable. Name it TIKTOK_ACCESS_TOKEN and paste your access token as the value. Enable the secret toggle so the token is restricted to resource configurations and never exposed to frontend JavaScript. Create a second configuration variable named TIKTOK_ADVERTISER_ID with your advertiser account ID — this will be referenced in query parameters rather than stored in the Resource itself, since many TikTok endpoints require it as a query parameter. Click Save on the Resource. Test the connection by creating a quick GET query to /advertiser/info/ with a URL parameter of advertiser_ids set to ["{{ config.TIKTOK_ADVERTISER_ID }}"] to confirm the token is valid.
Pro tip: TikTok's API authentication uses the header name Access-Token (not Authorization). This is a frequent source of 40001 errors during initial setup. Double-check the header name is exactly Access-Token with no space or different capitalization.
Expected result: The TikTok Marketing API Resource is saved in Retool with the base URL and Access-Token header configured. A test query to /advertiser/info/ returns the advertiser account details, confirming authentication is working.
Query campaign metrics using the TikTok Reporting API
TikTok's Reporting API uses a different pattern from most REST APIs: rather than querying /campaigns/insights, you POST a reporting request to /report/integrated/get/ with a structured JSON body specifying dimensions, metrics, and filters. Create a new query in Retool targeting your TikTok Marketing API resource. Set Method to GET (TikTok's integrated report endpoint accepts GET with query parameters, unlike the async report API). Set Path to /report/integrated/get/. In the URL Parameters section, add the following parameters. Add advertiser_id with value {{ retoolContext.configVars.TIKTOK_ADVERTISER_ID }}. Add report_type with value BASIC. Add dimensions with a JSON array value ["campaign_id","stat_time_day"] to get daily breakdown by campaign. Add metrics with a comma-separated string or JSON array of metric names: ["spend","impressions","clicks","ctr","cpm","cpc","reach","conversion","cost_per_conversion","video_play_actions","video_watched_2s","video_watched_6s"]. Add start_date and end_date parameters referencing your date picker component: start_date set to {{ formatDate(dateRangePicker.value[0], 'YYYY-MM-DD') }} and end_date set to {{ formatDate(dateRangePicker.value[1], 'YYYY-MM-DD') }}. Add data_level with value AUCTION_CAMPAIGN to get campaign-level data. Add page_size with value 200. Run the query — TikTok returns a data.list array with one object per dimension combination (one row per campaign per day). The response also includes a data.page_info object with total_number for pagination. Add a JavaScript transformer to the query in its Advanced tab to flatten the response and compute derived metrics like thumb-stop rate and video hold rate.
1// JavaScript transformer for TikTok Reporting API response2// Flatten nested metrics and compute video performance ratios3const rows = data.data?.list || [];45return rows.map(row => {6 const metrics = row.metrics || {};7 const dimensions = row.dimensions || {};89 const spend = parseFloat(metrics.spend || 0);10 const impressions = parseInt(metrics.impressions || 0);11 const clicks = parseInt(metrics.clicks || 0);12 const conversions = parseInt(metrics.conversion || 0);13 const videoPlays = parseInt(metrics.video_play_actions || 0);14 const watched2s = parseInt(metrics.video_watched_2s || 0);15 const watched6s = parseInt(metrics.video_watched_6s || 0);1617 return {18 campaign_id: dimensions.campaign_id || '',19 date: dimensions.stat_time_day || '',20 spend: spend.toFixed(2),21 spend_display: `$${spend.toFixed(2)}`,22 impressions: impressions,23 clicks: clicks,24 ctr: metrics.ctr ? (parseFloat(metrics.ctr) * 100).toFixed(2) + '%' : '0%',25 cpm: metrics.cpm ? `$${parseFloat(metrics.cpm).toFixed(2)}` : '$0',26 cpc: metrics.cpc ? `$${parseFloat(metrics.cpc).toFixed(2)}` : '$0',27 conversions: conversions,28 cost_per_conversion: metrics.cost_per_conversion29 ? `$${parseFloat(metrics.cost_per_conversion).toFixed(2)}`30 : 'N/A',31 thumb_stop_rate: impressions > 032 ? ((videoPlays / impressions) * 100).toFixed(1) + '%'33 : '0%',34 hold_rate: videoPlays > 035 ? ((watched6s / videoPlays) * 100).toFixed(1) + '%'36 : '0%',37 video_plays: videoPlays,38 watched_2s: watched2s,39 watched_6s: watched6s40 };41});Pro tip: TikTok's Reporting API requires all metric names to exactly match TikTok's documented metric identifiers. Unknown metric names cause a 40100 error rather than being silently ignored. Check the TikTok Marketing API documentation for the exact metric name list before adding new metrics to your query.
Expected result: The reporting query returns a transformed array of campaign-day records with spend, impressions, clicks, conversion counts, and video engagement ratios. The data is ready to bind to a Table and Chart components.
Build the TikTok Ads performance dashboard
With campaign reporting data available, build the dashboard layout in Retool. Add a DateRangePicker component at the top of the canvas to control the reporting window — set a default value of last 7 days and constrain the maximum range to 90 days. Drag a Table component onto the canvas and bind its data to {{ getCampaignMetrics.data }}. The transformer already flattened the response, so each row maps directly to a Table row. Configure column headers with user-friendly labels: rename spend_display to Spend, thumb_stop_rate to Thumb-Stop Rate, hold_rate to 6s Hold Rate. Enable column sorting so buyers can rank campaigns by any metric. Add conditional formatting: highlight rows where cost_per_conversion exceeds a threshold value (reference a Number input for the target CPA). Drag a Chart component below the Table and set Chart type to Line. Bind data to the daily reporting query results. Set the X axis to the date dimension and add series for spend and conversions on separate Y axes to show spend trend alongside conversion volume. Add a second Chart as a grouped Bar chart comparing spend, impressions, and conversions across campaigns for the period — this gives a visual performance snapshot. Place Stat components at the top showing period totals: calculate these in a JavaScript query that sums the campaign metrics array. For creative-level analysis, create a second query at data_level AUCTION_AD with dimensions ["ad_id","ad_name"] and bind it to a second Table tab, enabling buyers to drill from campaign to individual creative performance.
1// JavaScript query: compute period totals for Stat components2// Place this as a JavaScript query named 'computeTotals'3const rows = getCampaignMetrics.data || [];45const totalSpend = rows.reduce((sum, r) => sum + parseFloat(r.spend || 0), 0);6const totalImpressions = rows.reduce((sum, r) => sum + (parseInt(r.impressions) || 0), 0);7const totalClicks = rows.reduce((sum, r) => sum + (parseInt(r.clicks) || 0), 0);8const totalConversions = rows.reduce((sum, r) => sum + (parseInt(r.conversions) || 0), 0);9const blendedCPA = totalConversions > 010 ? (totalSpend / totalConversions).toFixed(2)11 : 'N/A';1213return {14 total_spend: `$${totalSpend.toFixed(2)}`,15 total_impressions: totalImpressions.toLocaleString(),16 total_conversions: totalConversions,17 blended_cpa: blendedCPA !== 'N/A' ? `$${blendedCPA}` : 'N/A',18 blended_ctr: totalImpressions > 019 ? ((totalClicks / totalImpressions) * 100).toFixed(2) + '%'20 : '0%'21};Pro tip: TikTok's Reporting API limits results to 1,000 rows per request. For large ad accounts with many campaigns, add pagination logic using the page parameter and data.page_info.total_number to fetch all results across multiple requests.
Expected result: A complete TikTok Ads dashboard displays period-total Stats at the top, a campaign performance Table with video engagement metrics, and spend/conversion trend Charts — all controlled by the date range picker at the top of the app.
Set up token refresh with a Retool Workflow
TikTok Marketing API access tokens expire after 24 hours, which would break your Retool dashboard daily without automated refresh. Retool Workflows can handle this automatically. Navigate to Workflows in Retool and click Create workflow. Name it TikTok Token Refresh. Add a Schedule trigger set to run every 20 hours (before the 24-hour expiry window). In the workflow canvas, add a Resource Query block targeting your TikTok Marketing API resource. Configure the block: Method GET, Path /oauth2/refresh_token/. In the URL parameters, add app_id referencing your app ID (store as a configuration variable TIKTOK_APP_ID) and secret referencing your App Secret (store as TIKTOK_APP_SECRET), plus refresh_token referencing a configuration variable TIKTOK_REFRESH_TOKEN where you have stored your refresh token. Add a JavaScript Code block after the query block. In the code block, read the new access_token from the previous block's response: const newToken = refreshTokenQuery.data.data.access_token;. To update the Retool configuration variable programmatically, use the Retool API (available under Settings → Retool API) with a POST to /api/v2/environment_variables/TIKTOK_ACCESS_TOKEN. This creates a fully automated refresh loop. For complex multi-source advertising integrations involving TikTok, Meta, Google, and custom attribution logic across multiple Retool Resources, RapidDev's team can architect and build a comprehensive paid media operations platform.
1// JavaScript Code block in Retool Workflow2// Reads new access token from refresh response and updates config variable3const response = refreshTokenQuery.data;45if (response.code !== 0) {6 throw new Error(`Token refresh failed: ${response.message}`);7}89const newAccessToken = response.data.access_token;10const newRefreshToken = response.data.refresh_token;1112// Log the refresh for debugging (check Workflow run logs)13console.log('TikTok token refreshed successfully at', new Date().toISOString());14console.log('New token expires in 24 hours');1516// Return token details for the workflow response block17return {18 success: true,19 access_token: newAccessToken,20 refresh_token: newRefreshToken,21 refreshed_at: new Date().toISOString()22};Pro tip: Store both the access_token and refresh_token in Retool configuration variables marked as secret. If the refresh_token itself expires (after 365 days), you will need to re-run the OAuth authorization flow manually. Set a calendar reminder to re-authorize annually.
Expected result: The TikTok Token Refresh Workflow runs every 20 hours, automatically refreshing the access token before it expires. The dashboard continues working without authentication interruptions.
Common use cases
TikTok campaign performance dashboard for media buyers
Build a Retool dashboard showing all active TikTok campaigns with performance metrics — spend, impressions, clicks, CTR, CPM, CPC, conversions, and ROAS — for a selected date range. A date range picker controls the reporting window, Charts show daily spend and conversion trends, and the Table supports sorting by any metric column so buyers can identify best and worst performing campaigns at a glance.
Build a Retool TikTok Ads dashboard that queries the Marketing API Reporting endpoint for all campaigns in an advertiser account with spend, impressions, clicks, ctr, cpm, cpc, and conversion metrics. Show a Table with all campaigns, a line Chart for daily spend, and Stat components showing period totals. Include a date range picker at the top to control the reporting window.
Copy this prompt to try it in Retool
Video creative performance analysis panel
Create a Retool panel that breaks down performance by individual ad (creative) to identify which video formats, hooks, and durations drive the best results. Query the Reporting API at the ad level with video-specific metrics like video_play_actions, video_watched_2s, video_watched_6s, and average_video_play to calculate thumb-stop rate and hold rate. Display a Table ranked by spend alongside video performance scores.
Build a Retool TikTok creative analysis panel that queries TikTok Marketing API at the ad level with spend, video_play_actions, video_watched_2s, video_watched_6s, clicks, and conversion. Calculate thumb-stop rate (video_play_actions / impressions) and hold rate (video_watched_6s / video_play_actions) in a JavaScript transformer. Display a Table ranked by spend with these calculated columns highlighted.
Copy this prompt to try it in Retool
Cross-platform paid media comparison dashboard
Combine TikTok Ads spend and conversion data with Facebook Ads and Google Ads metrics in a single Retool dashboard. Three parallel queries — TikTok Reporting API, Meta Insights API, and Google Ads API — run simultaneously, and a JavaScript transformer joins results by date to produce a unified daily view. Stakeholders see total paid media spend versus platform-by-platform ROAS without manually downloading reports from three separate platforms.
Build a Retool cross-platform paid media dashboard that queries TikTok Ads, Facebook Ads, and Google Ads APIs in parallel. Join the data by date in a JavaScript transformer and display total spend by platform in a stacked bar Chart, with a unified Table showing daily spend and conversions per platform. Include a platform filter dropdown to toggle which channels are shown.
Copy this prompt to try it in Retool
Troubleshooting
API returns error code 40001 with message 'Access token is invalid or does not exist'
Cause: The access token has expired (TikTok tokens expire after 24 hours), the Access-Token header name is incorrect, or the token was not properly stored in the configuration variable.
Solution: Check that the header name is exactly Access-Token (not Authorization or Bearer). Verify the token is still valid by testing it in TikTok's API Explorer. If expired, use the refresh_token to obtain a new access_token via the /oauth2/refresh_token/ endpoint. Implement the Retool Workflow token refresh described in Step 5 to prevent future expiration.
Reporting API returns empty data.list array despite active campaigns
Cause: The advertiser_id is incorrect, the data_level parameter does not match the selected dimensions, or the date range falls outside the retention window (TikTok keeps reporting data for 24 months).
Solution: Verify the advertiser_id matches the account ID shown in TikTok Ads Manager (visible in the URL when logged in). Confirm that the data_level value matches your dimensions: use AUCTION_CAMPAIGN with campaign_id dimension, AUCTION_ADGROUP with adgroup_id, and AUCTION_AD with ad_id. Test with a known active date range using explicit start_date and end_date values rather than dynamic picker references.
Error code 40100: 'The requested metric is not supported'
Cause: One or more metric names in the metrics parameter do not exactly match TikTok's documented metric identifiers. TikTok's metric names are case-sensitive and must match exactly.
Solution: Remove metrics from the query one by one to identify which metric name is invalid. Cross-reference with TikTok's Marketing API documentation reporting metrics reference page. Common mistakes: using 'cost_per_result' instead of 'cost_per_conversion', or 'video_views' instead of 'video_play_actions'. Build the metrics array incrementally, testing after each addition.
Reporting data is missing for recent days (today or yesterday)
Cause: TikTok's Reporting API has a data latency of 12-24 hours for most metrics. Data for the current day is incomplete and data for the previous day may still be processing.
Solution: Set the default date range to start 2 days ago and end 2 days ago for the most recent complete data. Display a note in the dashboard indicating reporting latency. For near-real-time monitoring, check TikTok's Ads Manager directly — the API is best suited for historical analysis rather than real-time dashboards.
Best practices
- Store the TikTok access token in a Retool configuration variable marked as secret — TikTok tokens are short-lived (24 hours), so automate refresh using a Retool Workflow rather than manually updating the variable.
- Always include the advertiser_id as a configuration variable rather than hardcoding it in queries — this makes it easy to switch between ad accounts or support multiple advertisers from the same Retool app.
- Use the AUCTION_CAMPAIGN data_level for campaign-level dashboards and switch to AUCTION_AD only when drilling into creative performance — ad-level data returns significantly more rows and is slower to query.
- Add video-specific metrics (video_play_actions, video_watched_2s, video_watched_6s) to your reporting queries — these TikTok-native engagement metrics are key to creative optimization and not available in other ad platforms.
- Enable Retool query caching (10-15 minutes) on all Reporting API queries — TikTok enforces rate limits per app and per advertiser, and caching significantly reduces API calls for multi-user dashboards.
- Limit date ranges to 90 days or fewer — TikTok's Reporting API performance degrades with longer date ranges, and most campaign optimization decisions only need recent data.
- Implement pagination logic for large ad accounts — the Reporting API returns a maximum of 1,000 rows per request, and accounts with many campaigns and long date ranges will require multiple paginated requests to retrieve complete data.
Alternatives
Facebook Ads connects via Meta's Marketing API using a System User token that never expires, making it simpler to maintain than TikTok's 24-hour access tokens, and is better suited for demographic and interest-based targeting campaigns.
Google Ads connects via REST API Resource using Google OAuth and the Google Ads API, and is preferred for search intent campaigns where users are actively looking for a product or service.
LinkedIn Ads connects via REST API Resource with OAuth 2.0 and is the better choice for B2B campaigns targeting by job title, company size, or industry rather than TikTok's interest and demographic-based audiences.
Frequently asked questions
Why do TikTok access tokens expire after 24 hours, and how do I handle this in Retool?
TikTok Marketing API access tokens are designed as short-lived credentials to reduce the risk of token misuse. The token expires exactly 24 hours after issuance. To prevent your Retool dashboard from breaking daily, implement a Retool Workflow with a schedule trigger that runs every 20 hours and calls the /oauth2/refresh_token/ endpoint using your refresh_token. Refresh tokens are valid for 365 days. Automate the configuration variable update using the Retool API from within the Workflow.
Can I build a single Retool dashboard combining TikTok, Meta, and Google Ads data?
Yes. Create separate REST API Resources for each platform: one for TikTok Marketing API, one for Meta Graph API, and one for Google Ads API. In your Retool app, run all three queries in parallel and use a JavaScript query to join the results by date or campaign. The join key is typically a date field present in all three responses. Display the combined data in a shared Table or stacked Bar Chart for cross-platform ROAS comparison.
What is the difference between TikTok's Reporting API and the Campaign API?
The Reporting API (/report/integrated/get/) is used for performance metrics — spend, impressions, clicks, conversions, and video engagement rates. It requires you to specify dimensions and metrics to produce aggregated reports. The Campaign API (/campaign/get/) returns campaign configuration data — name, status, objective, budget, schedule, and targeting settings — but not performance metrics. You typically use both: the Campaign API to list campaigns with their settings, and the Reporting API to get performance data for those campaigns.
Does Retool's server-side proxy handle TikTok API requests, or do I need to worry about CORS?
Retool Resource Queries proxy all requests through Retool's server-side infrastructure, so CORS is not an issue. Your TikTok access token and API calls never reach the browser. This is the primary advantage of using a Retool REST API Resource rather than making direct fetch() calls from a Retool JavaScript query — direct fetch calls run in a sandboxed iframe context and would encounter CORS restrictions.
Can I pause or modify TikTok ad campaigns from Retool?
Yes, if your access token has the Ad Management Write scope. Create a POST query targeting /campaign/update/ with the campaign_id and opt_status (ENABLE or DISABLE) in the request body. For budget updates, use /campaign/update/ with the budget field. Always add confirmation modals before executing status changes — pausing active campaigns has immediate business impact. Verify your developer app has the required write scopes enabled in TikTok for Developers.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation