VI | EN
Message us on Messenger
Developer resources

Start an async insights report — Facebook API

Async Insights Report · 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.

Async Insights Report

POST/{version}/act_{account_id}/insightsVia 360: POST https://partner.quantri360.com/v1/facebook/{version}/act_{account_id}/insights
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

Tạo báo cáo insight BẤT ĐỒNG BỘ cho kỳ dài / nhiều dòng (tránh lỗi quá thời gian của bản đọc trực tiếp GET /act_{account_id}/insights). Trả report_run_id; theo dõi tiến độ bằng GET /{version}/{object_id} (object_id = report_run_id) rồi đọc kết quả bằng GET /{version}/{object_id}/insights. Không thay đổi gì trên tài khoản.

  • Đường dẫn có act_<id> → 360 tự chọn token tài khoản. Tham số gửi trên query (đã gọi thật).
  • Theo dõi: GET /{version}/<report_run_id> trả async_status (Job Not Started · Job Started · Job Running · Job Completed · Job Failed · Job Skipped) và async_percent_completion (0–100). Xong khi Job Completed + 100. Gọi thật kỳ 30 ngày cấp chiến dịch: xong sau khoảng 4 giây.
  • Kết quả: GET /{version}/<report_run_id>/insights — cùng cấu trúc data / paging như bản GET, kèm date_start, date_stop.
  • report_run_id hết hạn sau 30 ngày — không lưu lâu dài. Job Skipped = báo cáo đã hết hạn, tạo lại. Job Failed = rà lại tham số (kỳ quá lớn → chia nhỏ kỳ).
  • Báo cáo lớn có thể chạy tới khoảng một giờ. Bản đồng bộ và bất đồng bộ dùng chung hạn mức tài khoản — vượt thì Meta trả code 4 / 17 / 80004.

Request

Endpoint

POST https://partner.quantri360.com/v1/facebook/{version}/act_{account_id}/insights

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_).
levelquerystringNocampaignaccount | campaign | adset | ad.
fieldsquerystringNocampaign_id,campaign_name,spend,impressions,clicks,actionsTrường insight như bản GET.
date_presetquerystringNolast_30dKhoảng có sẵn: today · yesterday · last_7d · last_30d · this_month · last_month …
time_rangequerystringNo{"since":"2026-01-01","until":"2026-10-29"}Hoặc khoảng ngày tự chọn (YYYY-MM-DD).
time_incrementquerystringNo11 = tách theo ngày; monthly = theo tháng.
breakdownsquerystringNoage,genderChiều phân rã.
filteringquerystringNo[{"field":"campaign.id","operator":"IN","value":["120250025975490254"]}]Bộ lọc JSON.

Request examples

curl -s -X POST "https://partner.quantri360.com/v1/facebook/v25.0/act_5924809560908319/insights?level=campaign&date_preset=last_30d&fields=campaign_id%2Ccampaign_name%2Cspend%2Cimpressions%2Cclicks" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
Python
import requests

KEY = "q360_live_..."  # khóa API của brand
r = requests.post(
    "https://partner.quantri360.com/v1/facebook/v25.0/act_5924809560908319/insights",
    params={
        "level": "campaign",
        "date_preset": "last_30d",
        "fields": "campaign_id,campaign_name,spend,impressions,clicks"
    },
    json={},
    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/insights');
for (const [k, v] of Object.entries({"level":"campaign","date_preset":"last_30d","fields":"campaign_id,campaign_name,spend,impressions,clicks"})) 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({}),
});
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/insights' . '?' . http_build_query(['level' => 'campaign', 'date_preset' => 'last_30d', 'fields' => 'campaign_id,campaign_name,spend,impressions,clicks']);
$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, '{}');
$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
report_run_idstring1446432480953387Id báo cáo — truyền vào `GET /{version}/{object_id}` và `GET /{version}/{object_id}/insights` (kèm `platform_shop_id=act_<id>`).

Response sample

{
  "report_run_id": "1446432480953387"
}

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