VI | EN
Message us on Messenger
Developer resources

Get rules by filters — TikTok Business API

Get rules by filters · call it through Quantri360 with one API key for your own accounts / assets that you connected and authorized — 360 handles request signing and refreshing the authorization you granted.

Get rules by filters

GET/optimizer/rule/list/Via 360: GET https://partner.quantri360.com/v1/tiktok_business/optimizer/rule/list/
Description

Use this endpoint to get rules based on the values of certain filters.

Request

Endpoint

GET https://partner.quantri360.com/v1/tiktok_business/optimizer/rule/list/

Authentication & shop

NameInTypeSampleDescription
AuthorizationheaderheaderBearer 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_idquerystring7000000000000000001Tà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

NameInTypeRequiredSampleDescription
filteringqueryobjectNoFilters.
tzonequerystringNoIf provided, all the time information in the response (create_datetime, email_exec_time, check_datetime, exec_datetime) will be shown in user specified timezone. For acceptable timezone code, see Time Zone.
pagequerynumberNoCurrent page number. Default: 1
page_sizequerynumberNoPage size. Default: 10

Request examples

curl -s "https://partner.quantri360.com/v1/tiktok_business/optimizer/rule/list/" \
  -H "Authorization: Bearer $KEY"
Python
import requests

KEY = "q360_live_..."  # khóa API của brand
r = requests.get(
    "https://partner.quantri360.com/v1/tiktok_business/optimizer/rule/list/",
    params={},
    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/optimizer/rule/list/');
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: 'GET',
  headers: { Authorization: `Bearer ${KEY}` },
});
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/optimizer/rule/list/' . '?' . http_build_query([]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $key]);
$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)

NameTypeSampleDescription
codenumberResponse code. For the complete list of response codes and descriptions, see Appendix - Return Codes.
messagestringResponse message. For details, see Appendix - Return Codes.
request_idstringUnique ID of the request
dataobjectReturned data.
rulesobject[]List of rules
apply_objectsobject[]Objects that you want to apply the rules to. Objects can be campaigns, ad groups, or ads.
dimesionstringCategory of the object. Enum values: `CAMPAIGN`, `ADGROUP`, `AD`.
dimension_idsstring[]IDs of the objects
pre_condition_typestringConditions to filter out objects that you do not want to include. Enum values: - `SELECTED`: Only include those that are selected by IDs. - `ALL_ACTIVE_CAMPAIGN`: Select all active campaigns. - `ALL_ACTIVE_AD_GROUP`: Select all active ad groups. - `ALL_ACTIVE_AD`: Select all active ads. - ` ALL_ACTIVE_AD_GROUP_UNDER_SELECTED`: Select all active ad groups under the selected campaign. - `ALL_ACTIVE_AD_UNDER_SELECTED`: Select all active ads under selected dimensions - `ALL_INACTIVE_CAMPAIGN`: Select all inactive campaigns. - `ALL_INACTIVE_AD_GROUP`: Select all inactive ad groups - `ALL_INACTIVE_AD`: Select all inactive ads. - `ALL_INACTIVE_AD_GROUP_UNDER_SELECTED`: Select all inactive ad groups under the selected campaign. - `ALL_INACTIVE_AD_UNDER_SELECTED`: Select all inactive ads under the selected campaign or ad group (specified by `dimension` and `dimension_ids`)
bind_typestringBind type of the rule. Enum values: `BIND`, `UNBIND`
conditionsobject[]Conditions
subject_typestringSubjects that the condition will be based on. Enum values: - `COST` - `DAILY_BUDGET_SPENDING_RATE` - `LIFETIME_BUDGET_SPENDING_RATE` - `IMPRESSION` - `CLICK` - `CONVERSION` - `CONVERSION_SKAN` - `CVR` - `CVR_SKAN` - `CPA` - `CPM` - `CPC` - `CTR` - `COST_PER_RESULT` - `RESULT` - `RESULT_RATE` - `BID_STRATEGY` - `OPTIMIZATION_GOAL` - `OBJECTIVE` - `NAME` - `DAYS_SINCE_CREATION` - `NO_CONDITION` - `ROAS_PURCHASE` - `ROAS_IMPRESSION_ADS` - `ROAS_PURCHASE_SKAN` - `ROAS_COMPLETE_PAYMENT` - `ROAS_PURCHASES_ONSITE` - `NOT_REAL_TIME_CPA` - `NOT_REAL_TIME_CONVERSION` - `NOT_REAL_TIME_CVR`
range_typestringTime range for the condition. Enum values: - `TODAY` - `YESTERDAY` - `PAST_THREE_DAYS` - `PAST_FIVE_DAYS` - `PAST_SEVEN_DAYS` - `LIFETIME`
match_typestringOperator to connect a condition with a value. Enum values: - `GT` (greater than) - `LT` (less than) - `BETWEEN` - `MATCH` - `CONTAINS` - `NOT_CONTAINS` - `START_WITH` - `END_WITH` - `STRING_EQUAL`
valuesstring[]Values for the condition.
calculation_typestringEnum values: - `ALL_OBJECTS` - `OF_EACH_OBJECT`
actionobject[]Actions to be taken when the condition is met
subject_typestringType of actions to take. Enum values: `TURN_ON`, `TURN_OFF`, `MESSAGE`, `DAILY_BUDGET`, `LIFETIME_BUDGET`, `BID`
action_typestringEnum values: `INCREASE`, `DECREASE`, `ADJUST_TO`
value_typestringEnum values: `EXACT`, `PERCENT`
valueobjectWhen `action_type` is `INCREASE` or `DECREASE`, users can specify the maximum(if INCREASE) or minimum(if DECREASE) budget using `use_limit` and `limit`. When `action_type` is `ADJUST_TO`, no need to provide `use_limit` and `limit`.
frequency_infoobjectFrequency settings. It can be used when the action `subject_type` is `DAILY_BUDGET`, `LIFETIME_BUDGET`, or `BID`
typestringEnum values: - `ONLY_ONCE` - `ONCE_IN_24_H` - `ONCE_IN_48_H` - `ONCE_IN_1_W` - `CUSTOM`
custom_frequency_typestringCustom frequency type. Valid only when `type` is `CUSTOM`. Enum: - `N_MINTUE_Y_TIMES` - `N_HOUR_Y_TIMES` - `N_DAY_Y_TIMES`
timenumberIt is the `N` in `custom_frequency_type`
countnumberIt is the `Y` in `custom_frequency_type`
notificationobjectNotification settings
notification_typestringNotification type you need. Enum values: - `TASK_FINISH`: Notification will be sent when the task is finished. This option is only for `MESSAGE` subject type. - `ANY_CHANGES`: If the `subject_type` for the action is not `MESSAGE` but you still want to receive emails, use this option. - `NOT_NOTIFICATION`: No notifications are needed.
email_settingobjectEmail notification settings
notification_periodstringEnum values: - `EVERY_TIME` - `TIME_SCHEDULE`: notifications will be sent together around a specified time.
email_exec_timestring[]Required when `notification_period` is `TIME_SCHEDULE`. Notification email sent time. For example, "12:00".
no_result_notificationbooleanIt will be set as false by default if not provided, meaning no notification will be sent if there is no result.
rule_exec_infoobjectRule run settings
exec_time_typestringWhen the rule will be run. Enum values: - `PER_HALF_HOUR`: the rule will be run every half hour. - `CUSTOM`: the rule will be run at a customized time (specified in the `exec_time` field). - `HALF_HOUR_IN_SPECIFIC_TIME_PERIOD`: the rule will be run every 30 minutes during specified time range on specifed days during the week. - `SPECIFIC_TIME_ACCURATE_ONCE`: the rule will be run only once at a customized time (specified in the `exec_time` field).
exec_timestringIf `exec_time_type` is set to `CUSTOM` or `SPECIFIC_TIME_ACCURATE_ONCE`, use this field to specify the exact time when the rule will be run. Format: - "HH:MM" when `exec_time_type` is `CUSTOM`. For example: "12:00". - "YYYY-MM-DD HH:MM" when `exec_time_type` is `SPECIFIC_TIME_ACCURATE_ONCE`. For example: "2023-04-20 04:20".
time_period_infoobject[]Valid when `exec_time_type` is `HALF_HOUR_IN_SPECIFIC_TIME_PERIOD`. It has `start_time`, `end_time`, `date_type` and `num` to specify the time period information.
numintegers[]Each number in the list represents the day in the week or month. - When `date_type` is `WEEK`, value range for this field is [1, 7], meaning Monday to Sunday. - When `date_type` is `MONTH`, value range for this field is [1, 28], meaning 1st day to the 28th day of the month.
start_timestringStart time of this time period. For example, "12:00".
end_timestringEnd time of this time period. For example, "12:00".
date_typestringType of date. Enum values: `DAY`, `WEEK`, `MONTH`
last_check_result_summaryobjectInformation about the last rule run
check_datetimestringDate and time when the rule was checked, in UTC+0 time zone
exec_datetimestringDate and time when the rule was run, in UTC+0 time zone
change_successnumberObjects that have been changed
no_changenumberObjects that have not been changed
change_failnumberObjects that failed to be changed
task_exec_idstringRule execution ID
rule_idstringID of the rule
namestringName of the rule
rule_statusstringRule status. Enum values: - `ON`: on. - `OFF`: off. - `DELETED`: deleted.
create_datetimestringDate and time when the rule was created, in UTC+0 time zone

Response sample

{
    "code": 0,
    "message": "OK",
    "request_id": "2021072906564801024501305243095511",
    "data": {
        "rules": [
            {
                "last_check_result_summary": {
                    "change_success": 1,
                    "change_fail": 0,
                    "exec_datetime": "2021-07-12 06:00:00",
                    "task_exec_id": "6983915767100080129",
                    "not_change": 0,
                    "check_datetime": "2021-07-12 06:00:00"
                },
                "rule_id": "6982553361971232769",
                "notification": {
                    "notification_type": "TASK_FINISH"
                },
                "conditions": [
                    {
                        "subject_type": "CLICK",
                        "match_type": "GT",
                        "values": [
                            "0"
                        ],
                        "range_type": "LIFETIME"
                    }
                ],
                "name": "[API]Automated Rule--20210712-PPE-8",
                "rule_exec_info": {
                    "exec_time_type": "PER_HALF_HOUR",
                    "exec_time": ""
                },
                "create_datetime": "2021-07-12 04:43:56",
                "actions": [
                    {
                        "subject_type": "MESSAGE"
                    }
                ],
                "rule_status": "OFF",
                "apply_objects": [
                    {
                        "dimension_ids": [
                            "1695172996977714"
                        ],
                        "pre_condition_type": "SELECTED",
                        "dimension": "CAMPAIGN",
                        "bind_type": "BIND"
                    }
                ]
            },
            {
                "last_check_result_summary": {
                    "change_success": 0,
                    "change_fail": 0,
                    "exec_datetime": "0001-01-01 00:00:00",
                    "task_exec_id": "0",
                    "not_change": 0,
                    "check_datetime": "0001-01-01 00:00:00"
                },
                "rule_id": "6984697088064290818",
                "notification": {
                    "notification_type": "TASK_FINISH"
                },
                "conditions": [
                    {
                        "subject_type": "CLICK",
                        "match_type": "GT",
                        "values": [
                            "1"
                        ],
                        "range_type": "LIFETIME"
                    }
                ],
                "name": "[API]Automated Rule--example-update",
                "rule_exec_info": {
                    "exec_time_type": "PER_HALF_HOUR",
                    "exec_time": ""
                },
                "create_datetime": "2021-07-29 06:45:04",
                "actions": [
                    {
                        "subject_type": "MESSAGE"
                    }
                ],
                "rule_status": "ON",
                "apply_objects": [
                    {
                        "dimension_ids": [
                            "1694011873852465"
                        ],
                        "pre_condition_type": "SELECTED",
                        "dimension": "CAMPAIGN",
                        "bind_type": "BIND"
                    }
                ]
            }
        ]
    }
}

Get started

  1. Sign up for Partner
  2. Enable a data type of the Ads (Marketing API) group on the platform page
  3. Create an API key (tick the TikTok Business channel)
  4. Call it as in the examples above