VI | EN
Message us on Messenger
Developer resources

Preview a creative spec before creating — Facebook API

Generate Previews · 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.

Generate Previews

GET/{version}/act_{account_id}/generatepreviewsVia 360: GET https://partner.quantri360.com/v1/facebook/{version}/act_{account_id}/generatepreviews
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

Xem trước quảng cáo từ một creative CHƯA tạo (bài viết có sẵn hoặc nội dung soạn tại chỗ) ở một vị trí hiển thị: trả đoạn HTML <iframe> để nhúng. Dùng để duyệt nội dung trước khi tạo quảng cáo thật.

  • Đường dẫn có act_<id> → 360 tự chọn token tài khoản.
  • Link trong iframe có hạn — sinh lại mỗi lần cần xem, không lưu.
  • Xem trước quảng cáo ĐÃ tạo dùng GET /{version}/{ad_id}/previews.

Request

Endpoint

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

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_).
creativequerystringYes{"object_story_id":"560456991027063_1661625382331897"}JSON creative: object_story_id (<page_id>_<post_id> bài có sẵn) hoặc object_story_spec ({page_id, link_data{…}} soạn tại chỗ).
ad_formatquerystringYesMOBILE_FEED_STANDARDVị trí: MOBILE_FEED_STANDARD · DESKTOP_FEED_STANDARD · INSTAGRAM_STANDARD · INSTAGRAM_STORY · FACEBOOK_REELS_MOBILE · RIGHT_COLUMN_STANDARD …

Request examples

curl -s "https://partner.quantri360.com/v1/facebook/v25.0/act_5924809560908319/generatepreviews?creative=%7B%22object_story_id%22%3A%22560456991027063_1661625382331897%22%7D&ad_format=MOBILE_FEED_STANDARD" \
  -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/generatepreviews",
    params={
        "creative": "{\"object_story_id\":\"560456991027063_1661625382331897\"}",
        "ad_format": "MOBILE_FEED_STANDARD"
    },
    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/generatepreviews');
for (const [k, v] of Object.entries({"creative":"{\"object_story_id\":\"560456991027063_1661625382331897\"}","ad_format":"MOBILE_FEED_STANDARD"})) 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/generatepreviews' . '?' . http_build_query(['creative' => '{"object_story_id":"560456991027063_1661625382331897"}', 'ad_format' => 'MOBILE_FEED_STANDARD']);
$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[]Một dòng.
bodystring<iframe src="https://business.facebook.com/ads/api/preview_iframe.php?d=…" width="…" height="…" scrolling="yes" style="border: none;"></iframe>HTML `<iframe>` nhúng thẳng vào trang.

Response sample

{
  "data": [
    {
      "body": "<iframe src=\"https://business.facebook.com/ads/api/preview_iframe.php?d=AQK9mlB1…&t=AQ…\" width=\"320\" height=\"450\" scrolling=\"yes\" style=\"border: none;\"></iframe>"
    }
  ]
}

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