Search for location targeting tags
Use this endpoint to search for location targeting tags by keyword.
You can search for two types of targeting tags that are used to target ad audiences: zip code IDs (currently only supported for the US) or postal code IDs (Canada, Brazil, Indonesia, Thailand, and Vietnam) and location IDs. Then to apply targeting tags to your ads, you can pass the returned zip code IDs or postal code IDs to zipcode_ids or location IDs to location_ids when calling /adgroup/create/, /adgroup/update/ or /ad/audience_size/estimate/.
Both /tool/region/ and /tool/targeting/search/ can be used to get location IDs.
>Note
- This endpoint requires POST method, because for GET requests the length of URL will be limited.
- Targeting postal code areas in Brazil, Indonesia, Thailand, and Vietnam is currently an allowlist-only feature. If you would like to access it, please contact your TikTok representative.
- Targeting the newly available countries or regions (Azerbaijan, Bulgaria, Bolivia, Cyprus, Algeria, Estonia, Croatia, Kenya, Sri Lanka, Lithuania, Latvia, Nigeria, Puerto Rico, Paraguay, Serbia, Slovenia, Slovakia) using the advertising objective
TRAFFIC,LEAD_GENERATION,APP_PROMOTION, orWEB_CONVERSIONSand the TikTok placement are currently separate allowlist-only features. If you would like to access them, contact your TikTok representative. You need to apply for a separate allowlist for each newly available country or region. - Targeting the newly available countries or regions (Azerbaijan, Bulgaria, Bolivia, Cyprus, Algeria, Estonia, Croatia, Kenya, Sri Lanka, Lithuania, Latvia, Puerto Rico, Paraguay, Serbia, Slovenia, Slovakia) using the advertising objective
REACH,VIDEO_VIEWS, orENGAGEMENTand the TikTik placement are currently separate allowlist-only features. If you would like to access them, contact your TikTok representative. You need to apply for a separate allowlist for each newly available country or region. - When you target these countries or regions using the advertising objective
REACH,VIDEO_VIEWS, orENGAGEMENT, pre-bid third-party Brand Safety solutions are not supported. Therefore, you cannot setbrand_safety_typetoTHIRD_PARTY.
Request
Endpoint
Authentication & shop
| Name | In | Type | Sample | Description |
|---|---|---|---|---|
| Authorization | header | header | Bearer q360_live_ab12cd34_… | Khóa API của brand (tạo ở mục API key). Bắt buộc với mọi request. Brand suy từ key — không truyền mã brand. |
| platform_shop_id | query | string | 7000000000000000001 | Tài sản TikTok Business đã kết nối — "Mã tài sản" ở trang Nền tảng hoặc GET /v1/platforms (tài khoản quảng cáo cho Marketing API, tài khoản TikTok cho Organic / Messaging). Có thể bỏ khi chỉ kết nối một tài sản. |
Request parameters
| Name | In | Type | Required | Sample | Description |
|---|---|---|---|---|---|
| objective_type | body | string | Yes | Campaign objective.
The allowed enum values: REACH, TRAFFIC, VIDEO_VIEWS, LEAD_GENERATION, ENGAGEMENT, APP_PROMOTION, WEB_CONVERSIONS, PRODUCT_SALES.
For descriptions of the objectives, see Objectives. | |
| promotion_type | body | string | No | Promotion type and you can decide where you'd like to promote your products using this field. You need to specify the field when advertising objective (objective_type) for your campaign is NOT set as REACH, VIDEO_VIEWS, or ENGAGEMENT.
For enum values, see Enumeration - Promotion Type. | |
| placements | body | string[] | Yes | The apps where you want to deliver your ads.
For enum values, see Enumeration - Placement.
Note: If you want to fuzzy search for a zip code ID to be used for zip code targeting or a postal code ID to be used for postal code targeting, the value of this field needs to include PLACEMENT_TIKTOK. | |
| search_type | body | string | Yes | The type of search you want to perform.
Enum values:
- FUZZY_SEARCH: To fuzzy search for a single location ID, a zip code ID, or a postal code ID.
For this search type, you can only pass one keyword to keywords and a maximum of 100 results will be returned.
- BATCH_REGION_SEARCH: To search for location IDs in batch. Fuzzy search is supported.
For this search type, you can pass up to 1,000 keywords to keywords, and for each keyword a maximum of 5 results ordered by relevance will be returned.
- BATCH_ZIPCODE_SEARCH: To search for zip code IDs or postal code IDs in batch. Exact search is supported.
For this search type, you can pass up to 1,000 keywords to keywords, and for each keyword one result or no result will be returned.
Note:
- Targeting postal code areas in Brazil, Indonesia, Thailand, and Vietnam is currently an allowlist-only feature. If you would like to access it, please contact your TikTok representative.
- The enum values BATCH_ZIPCODE_SEARCH and BATCH_REGION_SEARCH can only be used to search for IDs of zip codes (or postal codes) or locations. In contrast, you can use FUZZY_SEARCH to search for a single ID of a zip code (or postal code) or location. | |
| keywords | body | string[] | Yes | The keywords that you use to search for targeting tags.
Length limit:
- 1 when search_type is FUZZY_SEARCH.
- 1,000 when search_type is BATCH_REGION_SEARCH or BATCH_ZIPCODE_SEARCH.
If you set search_type as BATCH_ZIPCODE_SEARCH, you need to pass zip codes or postal codes as keywords because this search type only supports exact search.
- For US zip code targeting, provide the five-digit US zip codes as keywords. Example: ["10001","10002"].
- For Canadian postal code targeting, provide the three-character Forward Sortation Area (FSA) portions of Canadian postal codes as keywords. Example: ["A0A","A0B"].
- For Brazil postal code targeting, provide the first five digits of postal codes as keywords. Example: ["81480","18072"].
- For Indonesia postal code targeting, provide the five-digit postal codes as keywords. Example: ["20371","12120"].
- For Thailand postal code targeting, provide the five-digit postal codes as keywords. Example: ["30000","40000"].
- For Vietnam postal code targeting, provide the first three digits of postal codes as keywords. Example: ["718","719"]. | |
| geo_types | body | string[] | No | The types of locations that you want to filter the results by. Enum values: COUNTRY (country or region), PROVINCE (province), CITY (city or county), DISTRICT (district or city), DMA (DMA), ZIP_CODE (zip code or postal code).
- When you specify search_type as FUZZY_SEARCH, the allowed enum values for this field are ZIP_CODE, COUNTRY, PROVINCE, CITY, DISTRICT, and DMA.
- When you specify search_type as BATCH_ZIPCODE_SEARCH, the allowed enum value for this field is ZIP_CODE.
- When you specify search_type as BATCH_REGION_SEARCH, the allowed enum values for this field are COUNTRY, PROVINCE, CITY, DISTRICT, and DMA. | |
| region_codes | body | string[] | No | The codes of targeted countries or regions that you want to filter the results by.
- When you specify search_type as BATCH_ZIPCODE_SEARCH or BATCH_REGION_SEARCH, this field is required and needs to be set as US (the US) , CA (Canada), BR (Brazil), ID (Indonesia), TH (Thailand), or VN (Vietnam).
- When you specify search_type as FUZZY_SEARCH, this field is optional and you can pass any supported country or region code to this field. To find out the complete list of country or region codes, see Location code. | |
| operating_system | body | string | No | Device operating system that you want to target. Enum values: ANDROID, IOS. | |
| brand_safety_type | body | string | No | Brand safety type. Valid only when placements is set as PLACEMENT_TIKTOK. Default value: NO_BRAND_SAFETY. Enum values:
- NO_BRAND_SAFETY: To not use any brand safety solution. Full inventory, which means your ads may appear next to some content featuring mature themes.
- EXPANDED_INVENTORY: Use TikTok's brand safety solution. Expanded inventory means that your ads will appear next to content where most inappropriate content has been removed, and that does not contain mature themes. In the next API version, EXPANDED_INVENTORY will replace NO_BRAND_SAFETY and will be the default brand safety option.
- STANDARD_INVENTORY: Use TikTok's brand safety solution. Standard inventory means that ads will appear next to content that is appropriate for most brands.
- LIMITED_INVENTORY: Use TikTok's brand safety solution. Limited inventory means that your ads will not appear next to content that contains mature themes.
- THIRD_PARTY: Use a third-party brand safety solution. You also need to pass in a value to the brand_safety_partner field. To get the countries and regions that your ads can be deployed to based on your brand safety settings, use the /tool/region/ endpoint.
Note:
- Pre-bid first-party Brand Safety solutions for APP_PROMOTION, WEB_CONVERSIONS, TRAFFIC, LEAD_GENERATION objectives in Auction ads, and pre-bid third-party brand safety solutions are currently allowlist-only features. If you would like to access them, please contact your TikTok representative.
- See Brand safety to learn about the supported advertising objectives for pre-bid Brand Safety filtering. | |
| brand_safety_partner | body | string | No | Required only when brand_safety_type is THIRD_PARTY.
Brand safety partner.
Enum values: IAS, OPEN_SLATE(The partner is named DoubleVerify on TikTok Ads Manager because the partner has been acquired by DoubleVerify).
Note: Pre-bid third-party brand safety solutions are currently allowlist-only features. If you would like to access them, please contact your TikTok representative. |
Request examples
curl -s -X POST "https://partner.quantri360.com/v1/tiktok_business/tool/targeting/search/" \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{"objective_type":"","placements":[],"search_type":"","keywords":[]}'
Python
import requests
KEY = "q360_live_..." # khóa API của brand
r = requests.post(
"https://partner.quantri360.com/v1/tiktok_business/tool/targeting/search/",
params={},
json={
"objective_type": "",
"placements": [],
"search_type": "",
"keywords": []
},
headers={"Authorization": f"Bearer {KEY}"},
timeout=60,
)
print(r.status_code)
print(r.json())Node.js
const KEY = 'q360_live_...'; // khóa API của brand
const url = new URL('https://partner.quantri360.com/v1/tiktok_business/tool/targeting/search/');
for (const [k, v] of Object.entries({})) url.searchParams.set(k, typeof v === 'object' ? JSON.stringify(v) : String(v));
const r = await fetch(url, {
method: 'POST',
headers: { Authorization: `Bearer ${KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({"objective_type":"","placements":[],"search_type":"","keywords":[]}),
});
console.log(r.status, await r.json());PHP
<?php
$key = 'q360_live_...'; // khóa API của brand
$url = 'https://partner.quantri360.com/v1/tiktok_business/tool/targeting/search/' . '?' . http_build_query([]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $key, 'Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"objective_type":"","placements":[],"search_type":"","keywords":[]}');
$res = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $status, "\n", $res;Response
Response fields (as returned by TikTok Business)
| Name | Type | Sample | Description |
|---|---|---|---|
| code | number | Response code. For the complete list of response codes and descriptions, see Appendix-Return Code. | |
| message | string | Response message. For details, see Appendix - Return Codes. | |
| request_id | string | The log ID of a request, which uniquely identifies the request. | |
| data | object | Returned data. | |
| targeting_tag_list | object[] | Information about the targeting tags that are matched by the specified keyword or keywords. Note: Multiple targeting tags of different names (`name`) may be returned for the same `keyword`. | |
| keyword | string | The keyword that is used to search for targeting tags. | |
| targeting_type | string | The targeting type that the targeting tag is used for. Enum values: `GEO` (Geographical targeting, which consists of administrative region targeting and zip code targeting (or postal code targeting)). | |
| name | string | The name of the targeting tag. | |
| status_info | object | Information about the status of the targeting tag. | |
| status | string | The status of the targeting tag. Enum values: `ENABLED` (can be used for targeting), `DISABLED` (cannot be used for targeting). | |
| reason | string | The reason why the targeting tag cannot be used for targeting. Returned when `status` = `DISABLED`. Enum values: - `OFFLINE`: The targeting tag is offline. - `NOT_SUPPORTED`: The targeting tag is not offline but is not supported for the specified settings. | |
| geo | object | Information about the targeting tag that is used for location targeting. Returned when `targeting_type` is `GEO`. | |
| geo_id | string | Location ID, zip code ID, or postal code ID. Location IDs can be used for administrative region targeting while zip code IDs can be used for zip code targeting and postal code IDs can be used for postal code targeting. - When the corresponding `geo_type` is `ZIP_CODE`, you can pass the value of this field as zip code ID or postal code ID to `zipcode_ids` when calling /adgroup/create/, /adgroup/update/ or /ad/audience_size/estimate/. - When the corresponding `geo_type` is not `ZIP_CODE`, you can pass the value of this field as location ID to `location_ids` when calling /adgroup/create/, /adgroup/update/ or /ad/audience_size/estimate/. | |
| geo_type | string | The type of location that the `geo_id` corresponds to. Enum values: `COUNTRY` (country), `PROVINCE` (province), `CITY` (city or county), `DISTRICT` (district or city), `DMA` (DMA), `ZIP_CODE` (zip code or postal code). | |
| description | string | The description of the targeted location. | |
| region_code | string | The code of the country or region that the targeted location belongs to. | |
| parent_id | string | ID of the parent location. Returns `0` if no parent location exists. | |
| parent_tags | object[] | Information about all the parent targeting tags. | |
| targeting_type | string | The targeting type that the parent targeting tag is used for. Enum values: `GEO` (Geographical targeting, which consists of administrative region targeting and zip code targeting (or postal code targeting)). | |
| name | string | The name of the parent targeting tag. | |
| status_info | object | Information about the status of the parent targeting tag. | |
| status | string | The status of the parent targeting tag. Enum values: `ENABLED` (can be used for targeting), `DISABLED` (cannot be used for targeting). | |
| reason | string | The reason why the parent targeting tag cannot be used for targeting. Returned when `status` = `DISABLED`. Enum values: - `OFFLINE`: The parent targeting tag is offline. - `NOT_SUPPORTED`: The parent targeting tag is not offline but is not supported for the specified settings. | |
| geo | object | Information about the parent targeting tag that is used for location targeting. Returned when `targeting_type` is `GEO`. | |
| geo_id | string | Parent location ID, zip code ID, or postal code ID. - When the corresponding `geo_type` is `ZIP_CODE`, you can pass the value of this field to `zipcode_ids` when calling /adgroup/create/, /adgroup/update/ or /ad/audience_size/estimate/. - When the corresponding `geo_type` is not `ZIP_CODE`, you can pass the value of this field to `location_ids` when calling /adgroup/create/, /adgroup/update/ or /ad/audience_size/estimate/. | |
| geo_type | string | The type of location that the `geo_id` corresponds to. Enum values: `COUNTRY` (country), `PROVINCE` (province), `CITY` (city or county), `DISTRICT` (district or city), `DMA` (DMA), `ZIP_CODE` (zip code or postal code). | |
| description | string | The description of the parent location. | |
| region_code | string | The code of the country or region that the parent location belongs to. | |
| parent_id | string | ID of the parent location for the parent location. Returns `0` if no parent location exists. |
Response sample
HTTPS/1.1 200 OK
{
"code": 0,
"message": "OK",
"request_id": "{{request_id}}",
"data": {
"parent_tags": [
{
"status_info": {
"reason": null,
"status": "ENABLED"
},
"geo": {
"geo_id": "6251999",
"geo_type": "COUNTRY",
"parent_id": "0",
"region_code": "CA",
"description": "Country"
},
"isp": null,
"name": "Canada",
"targeting_type": "GEO"
},
{
"status_info": {
"reason": null,
"status": "ENABLED"
},
"geo": {
"geo_id": "6354959",
"geo_type": "PROVINCE",
"parent_id": "6251999",
"region_code": "CA",
"description": "province"
},
"isp": null,
"name": "Newfoundland and Labrador",
"targeting_type": "GEO"
}
],
"targeting_tag_list": [
{
"keyword": "A0A",
"status_info": {
"reason": null,
"status": "ENABLED"
},
"geo": {
"geo_id": "8124000000533",
"geo_type": "ZIP_CODE",
"parent_id": "6354959",
"region_code": "CA",
"description": "postcode"
},
"isp": null,
"name": "A0A",
"targeting_type": "GEO"
}
]
}
}
Get started
- Sign up for Partner
- Enable a data type of the Ads (Marketing API) group on the platform page
- Create an API key (tick the TikTok Business channel)
- Call it as in the examples above