VI | EN
Message us on Messenger
Developer resources

Automated rules of an account — Facebook API

Ad Rules · 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.

Ad Rules

GET/{version}/act_{account_id}/adrules_libraryVia 360: GET https://partner.quantri360.com/v1/facebook/{version}/act_{account_id}/adrules_library
Coming soon. This API already runs in production through 360 and pricing is being finalised — you can read the docs and prepare your integration now.
Description

Luật tự động của tài khoản (ví dụ "tắt quảng cáo khi chi > 30.000đ mà chưa có tin nhắn"): điều kiện đánh giá, hành động, lịch chạy, trạng thái. Dùng để rà luật đang bật, đối chiếu khi chiến dịch bị tắt tự động.

  • Đường dẫn có act_<id> → 360 tự chọn token tài khoản.
  • Giá trị tiền trong filters cùng đơn vị ngân sách (VND = đồng), dạng chuỗi.
  • Bộ lọc adset.id IN có thể chứa hàng trăm id (gọi thật: luật mẫu trỏ ~700 nhóm) — phản hồi rất dài, giữ limit nhỏ.
  • Có tên người tạo — xử lý như dữ liệu cá nhân.

Request

Endpoint

GET https://partner.quantri360.com/v1/facebook/{version}/act_{account_id}/adrules_library

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_idquerystringact_123456789 hoặc 1234567890Tài sản Facebook brand đã nối với 360: tài khoản quảng cáo (act_<id> hoặc <id>), Page id hoặc Pixel id — lấy ở GET /v1/platforms. Có thể bỏ khi đường dẫn đã chứa act_<id> / page id của brand.

Request parameters

NameInTypeRequiredSampleDescription
versionpathstringYesv25.0
account_idpathstringYes5924809560908319Id tài khoản quảng cáo (số, không có act_).
fieldsquerystringNoid,name,status,evaluation_spec,execution_spec,schedule_spec,created_time,updated_time,created_byTrường cần lấy. Không gửi = chỉ id, name.
limitqueryintNo25
afterquerystringNoCon trỏ trang kế.

Pagination

Lặp khi có paging.next: thêm after = paging.cursors.after.

Request examples

curl -s "https://partner.quantri360.com/v1/facebook/v25.0/act_5924809560908319/adrules_library?fields=id%2Cname%2Cstatus%2Cevaluation_spec%2Cexecution_spec%2Cschedule_spec%2Cupdated_time&limit=25" \
  -H "Authorization: Bearer $KEY"
Python
import requests

KEY = "q360_live_..."  # khóa API của brand
r = requests.get(
    "https://partner.quantri360.com/v1/facebook/v25.0/act_5924809560908319/adrules_library",
    params={
        "fields": "id,name,status,evaluation_spec,execution_spec,schedule_spec,updated_time",
        "limit": 25
    },
    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/facebook/v25.0/act_5924809560908319/adrules_library');
for (const [k, v] of Object.entries({"fields":"id,name,status,evaluation_spec,execution_spec,schedule_spec,updated_time","limit":25})) 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/facebook/v25.0/act_5924809560908319/adrules_library' . '?' . http_build_query(['fields' => 'id,name,status,evaluation_spec,execution_spec,schedule_spec,updated_time', 'limit' => 25]);
$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 Facebook)

NameTypeSampleDescription
dataobject[]Luật.
idstring23854305460760253Id luật — đọc lịch sử chạy ở `GET /{version}/{rule_id}/history`.
namestringoff ads
statusstringENABLED`ENABLED` · `DISABLED` · `HAS_ISSUES` (luật lỗi, ví dụ trỏ tới đối tượng đã xóa).
evaluation_specobject`evaluation_type` (`SCHEDULE` theo lịch | `TRIGGER` khi số liệu đổi) + `filters[{field, operator, value}]` — ví dụ `spent GREATER_THAN 30000`, `adset.id IN [...]`, `time_preset`, `entity_type`.
execution_specobject`execution_type` (`PAUSE` · `UNPAUSE` · `CHANGE_BUDGET` · `NOTIFICATION` …) + `execution_options` (người nhận thông báo, mức tăng giảm ngân sách…).
schedule_specobject`schedule_type`: `SEMI_HOURLY` (30 phút) · `HOURLY` · `DAILY` · `CUSTOM`.
created_time / updated_timestring2023-05-17T00:47:28+0700Theo múi giờ tài khoản.
created_byobject`{id, name}` người tạo — dữ liệu cá nhân.
pagingobject`{cursors: {before, after}}`.

Response sample

{
  "data": [
    {
      "id": "23854305460760253",
      "name": "off ads",
      "status": "ENABLED",
      "evaluation_spec": {
        "evaluation_type": "SCHEDULE",
        "filters": [
          {
            "field": "spent",
            "value": "23000",
            "operator": "GREATER_THAN"
          },
          {
            "field": "result",
            "value": "1",
            "operator": "LESS_THAN"
          },
          {
            "field": "adset.id",
            "value": [
              "23854305418270253",
              "23854305418300253"
            ],
            "operator": "IN"
          },
          {
            "field": "entity_type",
            "value": "ADSET",
            "operator": "EQUAL"
          },
          {
            "field": "time_preset",
            "value": "MAXIMUM",
            "operator": "EQUAL"
          }
        ]
      },
      "execution_spec": {
        "execution_type": "PAUSE",
        "execution_options": [
          {
            "field": "user_ids",
            "value": [
              "100000000000001"
            ],
            "operator": "EQUAL"
          },
          {
            "field": "alert_preferences",
            "value": {
              "instant": {
                "trigger": "CHANGE"
              }
            },
            "operator": "EQUAL"
          }
        ]
      },
      "schedule_spec": {
        "schedule_type": "SEMI_HOURLY"
      },
      "created_time": "2023-05-17T00:47:28+0700",
      "updated_time": "2023-12-06T03:24:19+0700",
      "created_by": {
        "name": "Nguyễn Văn A",
        "id": "100000000000001"
      }
    }
  ],
  "paging": {
    "cursors": {
      "before": "MTIwMjAyMDk2NjY5NzMwMjU0",
      "after": "MjM4NTQzMDU0NjA3NjAyNTMZD"
    }
  }
}

Get started

  1. Sign up for Partner
  2. Enable a data type of the Quảng cáo (Marketing API) group on the platform page
  3. Create an API key (tick the Facebook channel)
  4. Call it as in the examples above