Upload Ad Image
POST/{version}/act_{account_id}/adimagesGọi qua 360: POST https://partner.quantri360.com/v1/facebook/{version}/act_{account_id}/adimages
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ải một ảnh vào thư viện ảnh của tài khoản quảng cáo để dùng khi tạo nội dung quảng cáo (adcreatives). ENDPOINT GHI.
- Là API GHI — thêm ảnh thật vào tài khoản quảng cáo; 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ý.
- Gửi multipart/form-data với trường tệp
bytes. Gửi JSON thìbyteslà chuỗi base64 của ảnh, thân yêu cầu tối đa 256 KB và 360 không kiểm định dạng. - Gỡ ảnh khỏi tài khoản: Meta dùng DELETE /act_<id>/adimages với
hash— API này chưa mở qua 360.
Request
Địa chỉ
POST https://partner.quantri360.com/v1/facebook/{version}/act_{account_id}/adimages
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_). |
| bytes | body | file | Có | anh.jpg | Một ảnh jpg / jpeg / png tối đa 8 MB, gửi multipart/form-data. 360 kiểm định dạng theo nội dung tệp rồi chuyển đi. |
Ví dụ request
curl -s -X POST "https://partner.quantri360.com/v1/facebook/v25.0/act_1000000000000001/adimages" \ -H "Authorization: Bearer $KEY" \ -F "bytes=@anh.jpg"
Python
import requests
from contextlib import ExitStack
KEY = "q360_live_..."
with ExitStack() as stack:
files = [("bytes", stack.enter_context(open("anh.jpg", "rb")))]
r = requests.post("https://partner.quantri360.com/v1/facebook/v25.0/act_1000000000000001/adimages", params={}, data={}, files=files, headers={"Authorization": f"Bearer {KEY}"}, timeout=60)
print(r.status_code, r.json())Node.js
import { readFile } from 'node:fs/promises';
const KEY = 'q360_live_...';
const url = new URL('https://partner.quantri360.com/v1/facebook/v25.0/act_1000000000000001/adimages');
const form = new FormData();
form.append("bytes", new Blob([await readFile("anh.jpg")]), "anh.jpg");
const r = await fetch(url, { method: 'POST', headers: { Authorization: `Bearer ${KEY}` }, body: form });
console.log(r.status, await r.json());PHP
<?php
$key = 'q360_live_...';
$ch = curl_init('https://partner.quantri360.com/v1/facebook/v25.0/act_1000000000000001/adimages');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $key]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, ['bytes' => new CURLFile('anh.jpg')]);
echo curl_exec($ch);
curl_close($ch);Response
Tham số phản hồi (nguyên của Facebook)
| Tên | Kiểu | Mẫu | Mô tả |
|---|---|---|---|
| images | object | Ảnh vừa tải, khóa theo tên tệp. | |
| hash | string | 0a1b2c3d4e5f60718293a4b5c6d7e8f9 | Mã ảnh — dùng làm `image_hash` khi tạo nội dung quảng cáo. |
| url | string | https://example.com/anh.jpg | Link ảnh. |
Mẫu phản hồi
{
"images": {
"upload.jpg": {
"hash": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
"url": "https://example.com/anh.jpg"
}
}
}
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