Create Ad Set
POST/{version}/act_{account_id}/adsetsGọi qua 360: POST https://partner.quantri360.com/v1/facebook/{version}/act_{account_id}/adsets
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
Tạo nhóm quảng cáo (đối tượng, vị trí, ngân sách, lịch chạy, mục tiêu tối ưu) trong một chiến dịch. Gửi execution_options=["validate_only"] để chỉ kiểm tra. ENDPOINT GHI.
- Là API GHI — tạo nhóm quảng cáo thật; key cần quyền ghi (can_write) và gói mở module Quảng cáo, mỗi lần gọi được 360 ghi nhật ký.
- Nhóm không hợp với chiến dịch (vd mục tiêu tối ưu khác chiến lược giá thầu chi phí thấp nhất) → HTTP 400, lý do ở
error.error_user_msg. targeting,promoted_objectgửi dạng object JSON.
Request
Địa chỉ
POST https://partner.quantri360.com/v1/facebook/{version}/act_{account_id}/adsets
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 | |
| account_id | path | string | Có | 1000000000000001 | Id tài khoản quảng cáo đã nối (không gồm tiền tố act_). |
| name | body | string | Có | Nữ 25-40 HCM | Tên nhóm quảng cáo. |
| campaign_id | body | string | Không | 120200000000000001 | Chiến dịch chứa nhóm. Hoặc gửi campaign_spec (gồm name, objective, buying_type) để tạo chiến dịch mới cùng lúc. |
| optimization_goal | body | string | Không | OFFSITE_CONVERSIONS | Mục tiêu tối ưu (vd LINK_CLICKS, OFFSITE_CONVERSIONS, CONVERSATIONS, REACH). Phải hợp với mục tiêu + chiến lược giá thầu của chiến dịch. |
| billing_event | body | string | Không | IMPRESSIONS | Sự kiện tính tiền, thường IMPRESSIONS. |
| targeting | body | object | Không | {"geo_locations":{"countries":["VN"]},"age_min":25,"age_max":40,"targeting_automation":{"advantage_audience":0}} | Đối tượng nhắm. targeting_automation.advantage_audience (0 / 1) bắt buộc. Giá trị sở thích / địa điểm lấy ở GET /{version}/search. |
| daily_budget | body | int | Không | 200000 | Ngân sách ngày (VND: 200000 = 200.000đ) khi chiến dịch không giữ ngân sách. |
| lifetime_budget | body | int | Không | Ngân sách trọn đời — đi kèm end_time. | |
| bid_amount | body | int | Không | Giá thầu tối đa khi chiến lược giá thầu cần. | |
| start_time | body | string | Không | 2026-12-05T08:00:00+0700 | Giờ bắt đầu (ISO 8601). |
| end_time | body | string | Không | Giờ kết thúc — bắt buộc khi dùng lifetime_budget. | |
| promoted_object | body | object | Không | {"pixel_id":"1000000000000009","custom_event_type":"PURCHASE"} | Đối tượng được quảng bá (pixel + sự kiện, Trang…) theo mục tiêu. |
| status | body | string | Không | PAUSED | ACTIVE hoặc PAUSED. |
| execution_options | body | string[] | Không | ["validate_only"] | validate_only = chỉ kiểm tra, trả {"success": true} khi hợp lệ. |
Ví dụ request
curl -s -X POST "https://partner.quantri360.com/v1/facebook/v25.0/act_1000000000000001/adsets" \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Nữ 25-40 HCM","campaign_id":"120200000000000001","optimization_goal":"LINK_CLICKS","billing_event":"IMPRESSIONS","daily_budget":200000,"targeting":{"geo_locations":{"countries":["VN"]},"age_min":25,"age_max":40,"targeting_automation":{"advantage_audience":0}},"status":"PAUSED"}'
Python
import requests
KEY = "q360_live_..." # khóa API của brand
r = requests.post(
"https://partner.quantri360.com/v1/facebook/v25.0/act_1000000000000001/adsets",
params={},
json={
"name": "Nữ 25-40 HCM",
"campaign_id": "120200000000000001",
"optimization_goal": "LINK_CLICKS",
"billing_event": "IMPRESSIONS",
"daily_budget": 200000,
"targeting": {
"geo_locations": {
"countries": [
"VN"
]
},
"age_min": 25,
"age_max": 40,
"targeting_automation": {
"advantage_audience": 0
}
},
"status": "PAUSED"
},
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_1000000000000001/adsets');
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({"name":"Nữ 25-40 HCM","campaign_id":"120200000000000001","optimization_goal":"LINK_CLICKS","billing_event":"IMPRESSIONS","daily_budget":200000,"targeting":{"geo_locations":{"countries":["VN"]},"age_min":25,"age_max":40,"targeting_automation":{"advantage_audience":0}},"status":"PAUSED"}),
});
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_1000000000000001/adsets' . '?' . 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, '{"name":"Nữ 25-40 HCM","campaign_id":"120200000000000001","optimization_goal":"LINK_CLICKS","billing_event":"IMPRESSIONS","daily_budget":200000,"targeting":{"geo_locations":{"countries":["VN"]},"age_min":25,"age_max":40,"targeting_automation":{"advantage_audience":0}},"status":"PAUSED"}');
$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ả |
|---|---|---|---|
| id | string | 120200000000000002 | Id nhóm quảng cáo (không có khi `validate_only`). |
| success | bool | true | Chỉ có khi `validate_only`. |
Mẫu phản hồi
{
"id": "120200000000000002"
}
Bắt đầu dùng
- Đăng ký tài khoản Partner
- Mở loại dữ liệu thuộc nhóm Quảng cáo (Marketing API) ở trang nền tảng
- Tạo API key (tick kênh Facebook)
- Gọi theo ví dụ ở trên