Send Events
POST/{version}/{pixel_id}/eventsGọi qua 360: POST https://partner.quantri360.com/v1/facebook/{version}/{pixel_id}/events
Sắp mở. API này đã chạy thật qua 360 và đang được chốt giá — bạn có thể đọc tài liệu và chuẩn bị tích hợp trước.
Endpoint ghi — thay đổi dữ liệu trên Facebook. Key phải được tạo với tick "Cho phép gọi API ghi", nếu không sẽ nhận 403 write_not_allowed. Mỗi lần gọi được ghi nhật ký.
Mô tả API
Gửi sự kiện Conversions API (CAPI) tới Pixel / Dataset của brand — như 360 đẩy sự kiện Purchase offline. ENDPOINT GHI.
Request
Địa chỉ
POST https://partner.quantri360.com/v1/facebook/{version}/{pixel_id}/events
Xác thực & gian hàng
| Tên | Vị trí | Kiểu | Mẫu | Mô tả |
|---|---|---|---|---|
| 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 | act_123456789 hoặc 1234567890 | Tà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. |
Tham số request
| Tên | Vị trí | Kiểu | Bắt buộc | Mẫu | Mô tả |
|---|---|---|---|---|---|
| version | path | string | Có | v25.0 | |
| pixel_id | path | string | Có | 1234567890 | Pixel / Dataset id đã nối với 360. |
| data | body | object[] | Có | [{"event_name":"Purchase","event_time":1760893200,"action_source":"website","user_data":{"ph":["<sha256 sđt>"]},"custom_data":{"currency":"VND","value":259000}}] | Mảng sự kiện theo chuẩn CAPI (user_data đã băm SHA-256). |
| test_event_code | body | string | Không | TEST1234 | Mã test trong Events Manager (chỉ khi thử). |
Ví dụ request
curl -s -X POST "https://partner.quantri360.com/v1/facebook/v25.0/1234567890/events" \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{"data":[{"event_name":"Purchase","event_time":1760893200,"action_source":"website","user_data":{"ph":["<sha256>"]},"custom_data":{"currency":"VND","value":259000}}]}'
Python
import requests
KEY = "q360_live_..." # khóa API của brand
r = requests.post(
"https://partner.quantri360.com/v1/facebook/v25.0/1234567890/events",
params={},
json={
"data": [
{
"event_name": "Purchase",
"event_time": 1760893200,
"action_source": "website",
"user_data": {
"ph": [
"<sha256>"
]
},
"custom_data": {
"currency": "VND",
"value": 259000
}
}
]
},
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/1234567890/events');
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({"data":[{"event_name":"Purchase","event_time":1760893200,"action_source":"website","user_data":{"ph":["<sha256>"]},"custom_data":{"currency":"VND","value":259000}}]}),
});
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/1234567890/events' . '?' . 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, '{"data":[{"event_name":"Purchase","event_time":1760893200,"action_source":"website","user_data":{"ph":["<sha256>"]},"custom_data":{"currency":"VND","value":259000}}]}');
$res = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $status, "\n", $res;Response
Tham số phản hồi (nguyên của Facebook)
| Tên | Kiểu | Mẫu | Mô tả |
|---|---|---|---|
| events_received | int | 1 | |
| messages | string[] | [] | |
| fbtrace_id | string |
Bắt đầu dùng
- Đăng ký tài khoản Partner
- Mở loại dữ liệu thuộc nhóm Conversion API ở trang nền tảng
- Tạo API key (tick kênh Facebook)
- Gọi theo ví dụ ở trên