廣告
查詢廣告洞察資料
明確指定日期、時區、幣別、歸因期間及轉換動作,取得有數量上限的官方付費成效。缺失指標維持缺失。
POST /advertising-api/insights/query契約檢閱日期: · sha256:9aedef8d43dd4514
概覽
明確指定日期、時區、幣別、歸因期間及轉換動作,取得有數量上限的官方付費成效。缺失指標維持缺失。
成功 HTTP 回應可能表示請求已接受,並非已完成。背景工作請儲存回傳 ID,持續檢查同一操作直到完成。已排程或已接受的貼文,只有平台確認後才算已發布;用戶端逾時無法證明結果。
驗證與權限
權杖只能使用其擁有者持有的權利。每次請求會檢查工作空間成員資格、資源擁有權、所選工作空間及已授予能力。core 與 full 設定檔只變更顯示的工具,不會授予存取權。
請求欄位
「必填」是指在其父物件及所選分支內必填。必填子欄位不會使選填父物件變成必填。下列規則與欄位名稱均複製自契約。
| 欄位 / 分支 | 類型 / 必填 | 約束 |
|---|---|---|
$ | object在父物件中必填 |
|
workspace_id | string在父物件中必填 |
|
advertising_account_id | string在父物件中必填 |
|
level | string在父物件中必填 |
|
start_date | string在父物件中必填 |
|
end_date | string在父物件中必填 |
|
action_attribution_windows | array在父物件中必填 |
|
action_attribution_windows[] | string選填/項目 |
|
action_report_time | string在父物件中必填 |
|
conversion_action_type | string在父物件中必填 |
|
revenue_action_type | string在父物件中必填 |
|
after | string選填/項目 |
|
limit | integer選填/項目 |
|
完整 JSON Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"workspace_id": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"advertising_account_id": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"level": {
"type": "string",
"enum": [
"campaign",
"adset",
"ad"
]
},
"start_date": {
"type": "string",
"pattern": "^\\d{4}-\\d{2}-\\d{2}$"
},
"end_date": {
"type": "string",
"pattern": "^\\d{4}-\\d{2}-\\d{2}$"
},
"action_attribution_windows": {
"minItems": 1,
"maxItems": 1,
"type": "array",
"items": {
"type": "string",
"enum": [
"1d_click",
"7d_click",
"1d_view"
]
}
},
"action_report_time": {
"type": "string",
"enum": [
"impression",
"conversion"
]
},
"conversion_action_type": {
"type": "string",
"pattern": "^[a-z][a-z0-9_.]{0,99}$"
},
"revenue_action_type": {
"type": "string",
"pattern": "^[a-z][a-z0-9_.]{0,99}$"
},
"after": {
"type": "string",
"maxLength": 2048
},
"limit": {
"default": 25,
"type": "integer",
"minimum": 1,
"maximum": 50
}
},
"required": [
"workspace_id",
"advertising_account_id",
"level",
"start_date",
"end_date",
"action_attribution_windows",
"action_report_time",
"conversion_action_type",
"revenue_action_type"
],
"additionalProperties": false
}回應與完成
成功 HTTP 狀態:200。操作完成時: synchronous_http_response.
成功 HTTP 回應可能表示請求已接受,並非已完成。背景工作請儲存回傳 ID,持續檢查同一操作直到完成。已排程或已接受的貼文,只有平台確認後才算已發布;用戶端逾時無法證明結果。
「必填」是指在其父物件及所選分支內必填。必填子欄位不會使選填父物件變成必填。下列規則與欄位名稱均複製自契約。
| 欄位 / 分支 | 類型 / 必填 | 約束 |
|---|---|---|
$ | object在父物件中必填 | — |
contract_version | string在父物件中必填 |
|
source_id | string在父物件中必填 |
|
source_sha256 | string在父物件中必填 |
|
identity_verification | string在父物件中必填 |
|
currency | string在父物件中必填 |
|
timezone | string在父物件中必填 |
|
selection | object在父物件中必填 | — |
selection.provider_api_version | string在父物件中必填 |
|
selection.provider_account_id | string在父物件中必填 |
|
selection.currency | string在父物件中必填 |
|
selection.timezone | string在父物件中必填 |
|
selection.level | string在父物件中必填 |
|
selection.start_date | string在父物件中必填 |
|
selection.end_date | string在父物件中必填 |
|
selection.action_attribution_windows | array在父物件中必填 |
|
selection.action_attribution_windows[] | string選填/項目 |
|
selection.action_report_time | string在父物件中必填 |
|
selection.conversion_action_type | string在父物件中必填 |
|
selection.revenue_action_type | string在父物件中必填 |
|
complete | boolean在父物件中必填 | — |
rows | array在父物件中必填 |
|
rows[] | object選填/項目 | — |
rows[].row_id | string在父物件中必填 |
|
rows[].metrics | object在父物件中必填 | — |
rows[].metrics.spend | object在父物件中必填 | — |
rows[].metrics.spend.value | string | null在父物件中必填 | — |
rows[].metrics.spend.valueanyOf 1 | string在父物件中必填 |
|
rows[].metrics.spend.valueanyOf 2 | null在父物件中必填 | — |
rows[].metrics.spend.unit | string在父物件中必填 |
|
rows[].metrics.spend.availability | string在父物件中必填 |
|
rows[].metrics.spend.reason | string | null在父物件中必填 | — |
rows[].metrics.spend.reasonanyOf 1 | string在父物件中必填 |
|
rows[].metrics.spend.reasonanyOf 2 | null在父物件中必填 | — |
rows[].metrics.spend.input_refs | array在父物件中必填 |
|
rows[].metrics.spend.input_refs[] | string選填/項目 |
|
rows[].metrics.clicks | object在父物件中必填 | — |
rows[].metrics.clicks.value | string | null在父物件中必填 | — |
rows[].metrics.clicks.valueanyOf 1 | string在父物件中必填 |
|
rows[].metrics.clicks.valueanyOf 2 | null在父物件中必填 | — |
rows[].metrics.clicks.unit | string在父物件中必填 |
|
rows[].metrics.clicks.availability | string在父物件中必填 |
|
rows[].metrics.clicks.reason | string | null在父物件中必填 | — |
rows[].metrics.clicks.reasonanyOf 1 | string在父物件中必填 |
|
rows[].metrics.clicks.reasonanyOf 2 | null在父物件中必填 | — |
rows[].metrics.clicks.input_refs | array在父物件中必填 |
|
rows[].metrics.clicks.input_refs[] | string選填/項目 |
|
rows[].metrics.conversions | object在父物件中必填 | — |
rows[].metrics.conversions.value | string | null在父物件中必填 | — |
rows[].metrics.conversions.valueanyOf 1 | string在父物件中必填 |
|
rows[].metrics.conversions.valueanyOf 2 | null在父物件中必填 | — |
rows[].metrics.conversions.unit | string在父物件中必填 |
|
rows[].metrics.conversions.availability | string在父物件中必填 |
|
rows[].metrics.conversions.reason | string | null在父物件中必填 | — |
rows[].metrics.conversions.reasonanyOf 1 | string在父物件中必填 |
|
rows[].metrics.conversions.reasonanyOf 2 | null在父物件中必填 | — |
rows[].metrics.conversions.input_refs | array在父物件中必填 |
|
rows[].metrics.conversions.input_refs[] | string選填/項目 |
|
rows[].metrics.attributed_revenue | object在父物件中必填 | — |
rows[].metrics.attributed_revenue.value | string | null在父物件中必填 | — |
rows[].metrics.attributed_revenue.valueanyOf 1 | string在父物件中必填 |
|
rows[].metrics.attributed_revenue.valueanyOf 2 | null在父物件中必填 | — |
rows[].metrics.attributed_revenue.unit | string在父物件中必填 |
|
rows[].metrics.attributed_revenue.availability | string在父物件中必填 |
|
rows[].metrics.attributed_revenue.reason | string | null在父物件中必填 | — |
rows[].metrics.attributed_revenue.reasonanyOf 1 | string在父物件中必填 |
|
rows[].metrics.attributed_revenue.reasonanyOf 2 | null在父物件中必填 | — |
rows[].metrics.attributed_revenue.input_refs | array在父物件中必填 |
|
rows[].metrics.attributed_revenue.input_refs[] | string選填/項目 |
|
rows[].metrics.cpc | object在父物件中必填 | — |
rows[].metrics.cpc.value | string | null在父物件中必填 | — |
rows[].metrics.cpc.valueanyOf 1 | string在父物件中必填 |
|
rows[].metrics.cpc.valueanyOf 2 | null在父物件中必填 | — |
rows[].metrics.cpc.unit | string在父物件中必填 |
|
rows[].metrics.cpc.availability | string在父物件中必填 |
|
rows[].metrics.cpc.reason | string | null在父物件中必填 | — |
rows[].metrics.cpc.reasonanyOf 1 | string在父物件中必填 |
|
rows[].metrics.cpc.reasonanyOf 2 | null在父物件中必填 | — |
rows[].metrics.cpc.input_refs | array在父物件中必填 |
|
rows[].metrics.cpc.input_refs[] | string選填/項目 |
|
rows[].metrics.cpa | object在父物件中必填 | — |
rows[].metrics.cpa.value | string | null在父物件中必填 | — |
rows[].metrics.cpa.valueanyOf 1 | string在父物件中必填 |
|
rows[].metrics.cpa.valueanyOf 2 | null在父物件中必填 | — |
rows[].metrics.cpa.unit | string在父物件中必填 |
|
rows[].metrics.cpa.availability | string在父物件中必填 |
|
rows[].metrics.cpa.reason | string | null在父物件中必填 | — |
rows[].metrics.cpa.reasonanyOf 1 | string在父物件中必填 |
|
rows[].metrics.cpa.reasonanyOf 2 | null在父物件中必填 | — |
rows[].metrics.cpa.input_refs | array在父物件中必填 |
|
rows[].metrics.cpa.input_refs[] | string選填/項目 |
|
rows[].metrics.attributed_roas | object在父物件中必填 | — |
rows[].metrics.attributed_roas.value | string | null在父物件中必填 | — |
rows[].metrics.attributed_roas.valueanyOf 1 | string在父物件中必填 |
|
rows[].metrics.attributed_roas.valueanyOf 2 | null在父物件中必填 | — |
rows[].metrics.attributed_roas.unit | string在父物件中必填 |
|
rows[].metrics.attributed_roas.availability | string在父物件中必填 |
|
rows[].metrics.attributed_roas.reason | string | null在父物件中必填 | — |
rows[].metrics.attributed_roas.reasonanyOf 1 | string在父物件中必填 |
|
rows[].metrics.attributed_roas.reasonanyOf 2 | null在父物件中必填 | — |
rows[].metrics.attributed_roas.input_refs | array在父物件中必填 |
|
rows[].metrics.attributed_roas.input_refs[] | string選填/項目 |
|
totals | object在父物件中必填 | — |
totals.spend | object在父物件中必填 | — |
totals.spend.value | string | null在父物件中必填 | — |
totals.spend.valueanyOf 1 | string在父物件中必填 |
|
totals.spend.valueanyOf 2 | null在父物件中必填 | — |
totals.spend.unit | string在父物件中必填 |
|
totals.spend.availability | string在父物件中必填 |
|
totals.spend.reason | string | null在父物件中必填 | — |
totals.spend.reasonanyOf 1 | string在父物件中必填 |
|
totals.spend.reasonanyOf 2 | null在父物件中必填 | — |
totals.spend.input_refs | array在父物件中必填 |
|
totals.spend.input_refs[] | string選填/項目 |
|
totals.clicks | object在父物件中必填 | — |
totals.clicks.value | string | null在父物件中必填 | — |
totals.clicks.valueanyOf 1 | string在父物件中必填 |
|
totals.clicks.valueanyOf 2 | null在父物件中必填 | — |
totals.clicks.unit | string在父物件中必填 |
|
totals.clicks.availability | string在父物件中必填 |
|
totals.clicks.reason | string | null在父物件中必填 | — |
totals.clicks.reasonanyOf 1 | string在父物件中必填 |
|
totals.clicks.reasonanyOf 2 | null在父物件中必填 | — |
totals.clicks.input_refs | array在父物件中必填 |
|
totals.clicks.input_refs[] | string選填/項目 |
|
totals.conversions | object在父物件中必填 | — |
totals.conversions.value | string | null在父物件中必填 | — |
totals.conversions.valueanyOf 1 | string在父物件中必填 |
|
totals.conversions.valueanyOf 2 | null在父物件中必填 | — |
totals.conversions.unit | string在父物件中必填 |
|
totals.conversions.availability | string在父物件中必填 |
|
totals.conversions.reason | string | null在父物件中必填 | — |
totals.conversions.reasonanyOf 1 | string在父物件中必填 |
|
totals.conversions.reasonanyOf 2 | null在父物件中必填 | — |
totals.conversions.input_refs | array在父物件中必填 |
|
totals.conversions.input_refs[] | string選填/項目 |
|
totals.attributed_revenue | object在父物件中必填 | — |
totals.attributed_revenue.value | string | null在父物件中必填 | — |
totals.attributed_revenue.valueanyOf 1 | string在父物件中必填 |
|
totals.attributed_revenue.valueanyOf 2 | null在父物件中必填 | — |
totals.attributed_revenue.unit | string在父物件中必填 |
|
totals.attributed_revenue.availability | string在父物件中必填 |
|
totals.attributed_revenue.reason | string | null在父物件中必填 | — |
totals.attributed_revenue.reasonanyOf 1 | string在父物件中必填 |
|
totals.attributed_revenue.reasonanyOf 2 | null在父物件中必填 | — |
totals.attributed_revenue.input_refs | array在父物件中必填 |
|
totals.attributed_revenue.input_refs[] | string選填/項目 |
|
totals.cpc | object在父物件中必填 | — |
totals.cpc.value | string | null在父物件中必填 | — |
totals.cpc.valueanyOf 1 | string在父物件中必填 |
|
totals.cpc.valueanyOf 2 | null在父物件中必填 | — |
totals.cpc.unit | string在父物件中必填 |
|
totals.cpc.availability | string在父物件中必填 |
|
totals.cpc.reason | string | null在父物件中必填 | — |
totals.cpc.reasonanyOf 1 | string在父物件中必填 |
|
totals.cpc.reasonanyOf 2 | null在父物件中必填 | — |
totals.cpc.input_refs | array在父物件中必填 |
|
totals.cpc.input_refs[] | string選填/項目 |
|
totals.cpa | object在父物件中必填 | — |
totals.cpa.value | string | null在父物件中必填 | — |
totals.cpa.valueanyOf 1 | string在父物件中必填 |
|
totals.cpa.valueanyOf 2 | null在父物件中必填 | — |
totals.cpa.unit | string在父物件中必填 |
|
totals.cpa.availability | string在父物件中必填 |
|
totals.cpa.reason | string | null在父物件中必填 | — |
totals.cpa.reasonanyOf 1 | string在父物件中必填 |
|
totals.cpa.reasonanyOf 2 | null在父物件中必填 | — |
totals.cpa.input_refs | array在父物件中必填 |
|
totals.cpa.input_refs[] | string選填/項目 |
|
totals.attributed_roas | object在父物件中必填 | — |
totals.attributed_roas.value | string | null在父物件中必填 | — |
totals.attributed_roas.valueanyOf 1 | string在父物件中必填 |
|
totals.attributed_roas.valueanyOf 2 | null在父物件中必填 | — |
totals.attributed_roas.unit | string在父物件中必填 |
|
totals.attributed_roas.availability | string在父物件中必填 |
|
totals.attributed_roas.reason | string | null在父物件中必填 | — |
totals.attributed_roas.reasonanyOf 1 | string在父物件中必填 |
|
totals.attributed_roas.reasonanyOf 2 | null在父物件中必填 | — |
totals.attributed_roas.input_refs | array在父物件中必填 |
|
totals.attributed_roas.input_refs[] | string選填/項目 |
|
gaps | array在父物件中必填 |
|
gaps[] | string選填/項目 |
|
suggestions | array在父物件中必填 |
|
suggestions[] | object選填/項目 | — |
suggestions[].rule_id | string在父物件中必填 |
|
suggestions[].rule_version | number在父物件中必填 |
|
suggestions[].proposal | string在父物件中必填 |
|
suggestions[].input_refs | array在父物件中必填 |
|
suggestions[].input_refs[] | string選填/項目 |
|
suggestions[].limitations | string在父物件中必填 |
|
advertising_account_id | string在父物件中必填 |
|
next_cursor | string | null在父物件中必填 | — |
next_cursoranyOf 1 | string在父物件中必填 |
|
next_cursoranyOf 2 | null在父物件中必填 | — |
完整 JSON Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"contract_version": {
"type": "string",
"const": "ad-performance/v1"
},
"source_id": {
"type": "string",
"maxLength": 100
},
"source_sha256": {
"type": "string",
"pattern": "^[a-f0-9]{64}$"
},
"identity_verification": {
"type": "string",
"enum": [
"customer_supplied",
"accepted_provider_grant"
]
},
"currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"timezone": {
"type": "string",
"maxLength": 100
},
"selection": {
"type": "object",
"properties": {
"provider_api_version": {
"type": "string",
"const": "v26.0"
},
"provider_account_id": {
"type": "string",
"pattern": "^[1-9]\\d{1,24}$"
},
"currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"timezone": {
"type": "string",
"maxLength": 100
},
"level": {
"type": "string",
"enum": [
"campaign",
"adset",
"ad"
]
},
"start_date": {
"type": "string",
"pattern": "^\\d{4}-\\d{2}-\\d{2}$"
},
"end_date": {
"type": "string",
"pattern": "^\\d{4}-\\d{2}-\\d{2}$"
},
"action_attribution_windows": {
"minItems": 1,
"maxItems": 1,
"type": "array",
"items": {
"type": "string",
"enum": [
"1d_click",
"7d_click",
"1d_view"
]
}
},
"action_report_time": {
"type": "string",
"enum": [
"impression",
"conversion"
]
},
"conversion_action_type": {
"type": "string",
"maxLength": 100
},
"revenue_action_type": {
"type": "string",
"maxLength": 100
}
},
"required": [
"provider_api_version",
"provider_account_id",
"currency",
"timezone",
"level",
"start_date",
"end_date",
"action_attribution_windows",
"action_report_time",
"conversion_action_type",
"revenue_action_type"
]
},
"complete": {
"type": "boolean"
},
"rows": {
"maxItems": 500,
"type": "array",
"items": {
"type": "object",
"properties": {
"row_id": {
"type": "string",
"maxLength": 100
},
"metrics": {
"type": "object",
"properties": {
"spend": {
"type": "object",
"properties": {
"value": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d{1,24}(?:\\.\\d{1,6})?$"
},
{
"type": "null"
}
]
},
"unit": {
"type": "string",
"enum": [
"currency",
"count",
"currency_per_click",
"currency_per_conversion",
"ratio"
]
},
"availability": {
"type": "string",
"enum": [
"available",
"missing_input",
"zero_denominator",
"incompatible",
"partial"
]
},
"reason": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"input_refs": {
"maxItems": 2000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
}
},
"required": [
"value",
"unit",
"availability",
"reason",
"input_refs"
]
},
"clicks": {
"type": "object",
"properties": {
"value": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d{1,24}(?:\\.\\d{1,6})?$"
},
{
"type": "null"
}
]
},
"unit": {
"type": "string",
"enum": [
"currency",
"count",
"currency_per_click",
"currency_per_conversion",
"ratio"
]
},
"availability": {
"type": "string",
"enum": [
"available",
"missing_input",
"zero_denominator",
"incompatible",
"partial"
]
},
"reason": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"input_refs": {
"maxItems": 2000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
}
},
"required": [
"value",
"unit",
"availability",
"reason",
"input_refs"
]
},
"conversions": {
"type": "object",
"properties": {
"value": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d{1,24}(?:\\.\\d{1,6})?$"
},
{
"type": "null"
}
]
},
"unit": {
"type": "string",
"enum": [
"currency",
"count",
"currency_per_click",
"currency_per_conversion",
"ratio"
]
},
"availability": {
"type": "string",
"enum": [
"available",
"missing_input",
"zero_denominator",
"incompatible",
"partial"
]
},
"reason": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"input_refs": {
"maxItems": 2000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
}
},
"required": [
"value",
"unit",
"availability",
"reason",
"input_refs"
]
},
"attributed_revenue": {
"type": "object",
"properties": {
"value": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d{1,24}(?:\\.\\d{1,6})?$"
},
{
"type": "null"
}
]
},
"unit": {
"type": "string",
"enum": [
"currency",
"count",
"currency_per_click",
"currency_per_conversion",
"ratio"
]
},
"availability": {
"type": "string",
"enum": [
"available",
"missing_input",
"zero_denominator",
"incompatible",
"partial"
]
},
"reason": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"input_refs": {
"maxItems": 2000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
}
},
"required": [
"value",
"unit",
"availability",
"reason",
"input_refs"
]
},
"cpc": {
"type": "object",
"properties": {
"value": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d{1,24}(?:\\.\\d{1,6})?$"
},
{
"type": "null"
}
]
},
"unit": {
"type": "string",
"enum": [
"currency",
"count",
"currency_per_click",
"currency_per_conversion",
"ratio"
]
},
"availability": {
"type": "string",
"enum": [
"available",
"missing_input",
"zero_denominator",
"incompatible",
"partial"
]
},
"reason": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"input_refs": {
"maxItems": 2000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
}
},
"required": [
"value",
"unit",
"availability",
"reason",
"input_refs"
]
},
"cpa": {
"type": "object",
"properties": {
"value": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d{1,24}(?:\\.\\d{1,6})?$"
},
{
"type": "null"
}
]
},
"unit": {
"type": "string",
"enum": [
"currency",
"count",
"currency_per_click",
"currency_per_conversion",
"ratio"
]
},
"availability": {
"type": "string",
"enum": [
"available",
"missing_input",
"zero_denominator",
"incompatible",
"partial"
]
},
"reason": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"input_refs": {
"maxItems": 2000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
}
},
"required": [
"value",
"unit",
"availability",
"reason",
"input_refs"
]
},
"attributed_roas": {
"type": "object",
"properties": {
"value": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d{1,24}(?:\\.\\d{1,6})?$"
},
{
"type": "null"
}
]
},
"unit": {
"type": "string",
"enum": [
"currency",
"count",
"currency_per_click",
"currency_per_conversion",
"ratio"
]
},
"availability": {
"type": "string",
"enum": [
"available",
"missing_input",
"zero_denominator",
"incompatible",
"partial"
]
},
"reason": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"input_refs": {
"maxItems": 2000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
}
},
"required": [
"value",
"unit",
"availability",
"reason",
"input_refs"
]
}
},
"required": [
"spend",
"clicks",
"conversions",
"attributed_revenue",
"cpc",
"cpa",
"attributed_roas"
]
}
},
"required": [
"row_id",
"metrics"
]
}
},
"totals": {
"type": "object",
"properties": {
"spend": {
"type": "object",
"properties": {
"value": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d{1,24}(?:\\.\\d{1,6})?$"
},
{
"type": "null"
}
]
},
"unit": {
"type": "string",
"enum": [
"currency",
"count",
"currency_per_click",
"currency_per_conversion",
"ratio"
]
},
"availability": {
"type": "string",
"enum": [
"available",
"missing_input",
"zero_denominator",
"incompatible",
"partial"
]
},
"reason": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"input_refs": {
"maxItems": 2000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
}
},
"required": [
"value",
"unit",
"availability",
"reason",
"input_refs"
]
},
"clicks": {
"type": "object",
"properties": {
"value": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d{1,24}(?:\\.\\d{1,6})?$"
},
{
"type": "null"
}
]
},
"unit": {
"type": "string",
"enum": [
"currency",
"count",
"currency_per_click",
"currency_per_conversion",
"ratio"
]
},
"availability": {
"type": "string",
"enum": [
"available",
"missing_input",
"zero_denominator",
"incompatible",
"partial"
]
},
"reason": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"input_refs": {
"maxItems": 2000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
}
},
"required": [
"value",
"unit",
"availability",
"reason",
"input_refs"
]
},
"conversions": {
"type": "object",
"properties": {
"value": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d{1,24}(?:\\.\\d{1,6})?$"
},
{
"type": "null"
}
]
},
"unit": {
"type": "string",
"enum": [
"currency",
"count",
"currency_per_click",
"currency_per_conversion",
"ratio"
]
},
"availability": {
"type": "string",
"enum": [
"available",
"missing_input",
"zero_denominator",
"incompatible",
"partial"
]
},
"reason": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"input_refs": {
"maxItems": 2000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
}
},
"required": [
"value",
"unit",
"availability",
"reason",
"input_refs"
]
},
"attributed_revenue": {
"type": "object",
"properties": {
"value": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d{1,24}(?:\\.\\d{1,6})?$"
},
{
"type": "null"
}
]
},
"unit": {
"type": "string",
"enum": [
"currency",
"count",
"currency_per_click",
"currency_per_conversion",
"ratio"
]
},
"availability": {
"type": "string",
"enum": [
"available",
"missing_input",
"zero_denominator",
"incompatible",
"partial"
]
},
"reason": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"input_refs": {
"maxItems": 2000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
}
},
"required": [
"value",
"unit",
"availability",
"reason",
"input_refs"
]
},
"cpc": {
"type": "object",
"properties": {
"value": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d{1,24}(?:\\.\\d{1,6})?$"
},
{
"type": "null"
}
]
},
"unit": {
"type": "string",
"enum": [
"currency",
"count",
"currency_per_click",
"currency_per_conversion",
"ratio"
]
},
"availability": {
"type": "string",
"enum": [
"available",
"missing_input",
"zero_denominator",
"incompatible",
"partial"
]
},
"reason": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"input_refs": {
"maxItems": 2000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
}
},
"required": [
"value",
"unit",
"availability",
"reason",
"input_refs"
]
},
"cpa": {
"type": "object",
"properties": {
"value": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d{1,24}(?:\\.\\d{1,6})?$"
},
{
"type": "null"
}
]
},
"unit": {
"type": "string",
"enum": [
"currency",
"count",
"currency_per_click",
"currency_per_conversion",
"ratio"
]
},
"availability": {
"type": "string",
"enum": [
"available",
"missing_input",
"zero_denominator",
"incompatible",
"partial"
]
},
"reason": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"input_refs": {
"maxItems": 2000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
}
},
"required": [
"value",
"unit",
"availability",
"reason",
"input_refs"
]
},
"attributed_roas": {
"type": "object",
"properties": {
"value": {
"anyOf": [
{
"type": "string",
"pattern": "^\\d{1,24}(?:\\.\\d{1,6})?$"
},
{
"type": "null"
}
]
},
"unit": {
"type": "string",
"enum": [
"currency",
"count",
"currency_per_click",
"currency_per_conversion",
"ratio"
]
},
"availability": {
"type": "string",
"enum": [
"available",
"missing_input",
"zero_denominator",
"incompatible",
"partial"
]
},
"reason": {
"anyOf": [
{
"type": "string",
"maxLength": 300
},
{
"type": "null"
}
]
},
"input_refs": {
"maxItems": 2000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
}
},
"required": [
"value",
"unit",
"availability",
"reason",
"input_refs"
]
}
},
"required": [
"spend",
"clicks",
"conversions",
"attributed_revenue",
"cpc",
"cpa",
"attributed_roas"
]
},
"gaps": {
"maxItems": 1000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
},
"suggestions": {
"maxItems": 3,
"type": "array",
"items": {
"type": "object",
"properties": {
"rule_id": {
"type": "string",
"enum": [
"supply_revenue",
"review_comparable_creative_test",
"complete_coverage"
]
},
"rule_version": {
"type": "number",
"const": 1
},
"proposal": {
"type": "string",
"maxLength": 600
},
"input_refs": {
"maxItems": 2000,
"type": "array",
"items": {
"type": "string",
"maxLength": 300
}
},
"limitations": {
"type": "string",
"const": "Observational comparison only; no causal uplift or profitability claim. Human review required."
}
},
"required": [
"rule_id",
"rule_version",
"proposal",
"input_refs",
"limitations"
]
}
},
"advertising_account_id": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"next_cursor": {
"anyOf": [
{
"type": "string",
"maxLength": 2048
},
{
"type": "null"
}
]
}
},
"required": [
"contract_version",
"source_id",
"source_sha256",
"identity_verification",
"currency",
"timezone",
"selection",
"complete",
"rows",
"totals",
"gaps",
"suggestions",
"advertising_account_id",
"next_cursor"
]
}錯誤與安全重試
檢查 HTTP 狀態和回應內容。400 驗證錯誤可能包含 ZodError;處理常式錯誤使用 error、message 和 code 欄位。保留 request_id 或 x-request-id 以便診斷,但不要保留憑證。先解決 401/403 存取錯誤再重試,並在收到 429 時遵循 Retry-After。如寫入結果不確定或回傳 5xx,先讀取現有結果。僅在支援時重複使用冪等鍵;重試行為因操作而異,並不保證恰好傳送一次。
故障排查指南範例
這些範例使用已依結構描述檢查的虛構值。請將 ID 替換為您有權使用的 ID、將媒體替換為已就緒素材,並將日期替換為已確認的發布時間。提交寫入前,請檢查帳號資格。本頁不會傳送 API 請求。
在伺服器上將 SOSOAPI_ACCESS_TOKEN 設為此操作接受的憑證,且不要放入瀏覽器程式碼。AI 代理程式請使用 sosoapi auth login 透過瀏覽器登入,並由 CLI 更新憑證。
request.json
{
"workspace_id": "11111111-1111-4111-8111-111111111111",
"advertising_account_id": "11111111-1111-4111-8111-111111111111",
"level": "campaign",
"start_date": "2099-01-15",
"end_date": "2099-01-15",
"action_attribution_windows": [
"1d_click"
],
"action_report_time": "impression",
"conversion_action_type": "example",
"revenue_action_type": "example"
}cURL
curl --request POST \
"https://gqeshlawtcexsapabaui.supabase.co/functions/v1/advertising-api/insights/query" \
-H "Authorization: Bearer $SOSOAPI_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
--data-binary @request.jsonJavaScript
// Server-side JavaScript. Do not print tokens or credential-bearing responses.
const token = process.env.SOSOAPI_ACCESS_TOKEN;
if (!token) throw new Error("Set an accepted credential for this operation");
const response = await fetch("https://gqeshlawtcexsapabaui.supabase.co/functions/v1/advertising-api/insights/query", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: "Bearer " + token },
body: JSON.stringify({
"workspace_id": "11111111-1111-4111-8111-111111111111",
"advertising_account_id": "11111111-1111-4111-8111-111111111111",
"level": "campaign",
"start_date": "2099-01-15",
"end_date": "2099-01-15",
"action_attribution_windows": [
"1d_click"
],
"action_report_time": "impression",
"conversion_action_type": "example",
"revenue_action_type": "example"
})
});
const result = await response.json();
// Check response.ok, the operation-specific body and completion state before continuing.CLI
npx sosoapi api post /advertising-api/insights/query < request.json合成回應範例
{
"contract_version": "ad-performance/v1",
"source_id": "example",
"source_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"identity_verification": "customer_supplied",
"currency": "USD",
"timezone": "UTC",
"selection": {
"provider_api_version": "v26.0",
"provider_account_id": "12345",
"currency": "USD",
"timezone": "UTC",
"level": "campaign",
"start_date": "2099-01-15",
"end_date": "2099-01-15",
"action_attribution_windows": [
"1d_click"
],
"action_report_time": "impression",
"conversion_action_type": "example",
"revenue_action_type": "example"
},
"complete": false,
"rows": [],
"totals": {
"spend": {
"value": null,
"unit": "currency",
"availability": "available",
"reason": null,
"input_refs": []
},
"clicks": {
"value": null,
"unit": "currency",
"availability": "available",
"reason": null,
"input_refs": []
},
"conversions": {
"value": null,
"unit": "currency",
"availability": "available",
"reason": null,
"input_refs": []
},
"attributed_revenue": {
"value": null,
"unit": "currency",
"availability": "available",
"reason": null,
"input_refs": []
},
"cpc": {
"value": null,
"unit": "currency",
"availability": "available",
"reason": null,
"input_refs": []
},
"cpa": {
"value": null,
"unit": "currency",
"availability": "available",
"reason": null,
"input_refs": []
},
"attributed_roas": {
"value": null,
"unit": "currency",
"availability": "available",
"reason": null,
"input_refs": []
}
},
"gaps": [],
"suggestions": [],
"advertising_account_id": "11111111-1111-4111-8111-111111111111",
"next_cursor": null
}