# 分析廣告成效

標準 URL： https://sosoapi.ai/zh-tw/docs/api/advertising-api-performance-analyze

契約：sha256:9aedef8d43dd4514

使用明確歸因及確切來源雜湊，分析有數量上限的客戶提供付費報表。不會存取平台或聲稱獲利因果關係。

POST /advertising-api/performance/analyze

## 驗證與權限

- **接受的憑證類別：** user_session、delegated_oauth、personal_access_token

- **委派能力：** agent:advertising_read

- **最低工作空間角色：** viewer

- **存取範圍：** 此使用者獲准存取的資源

- **需要所有工作空間同意：** 否

- **變更狀態：** 否

- **操作完成時：** synchronous_http_response

權杖只能使用其擁有者持有的權利。每次請求會檢查工作空間成員資格、資源擁有權、所選工作空間及已授予能力。core 與 full 設定檔只變更顯示的工具，不會授予存取權。

## 請求欄位

```json
{
  "$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)$"
    },
    "source_kind": {
      "type": "string",
      "enum": [
        "customer_import",
        "official_meta_api"
      ]
    },
    "source_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "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",
      "minLength": 1,
      "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",
      "pattern": "^[a-z][a-z0-9_.]{0,99}$"
    },
    "revenue_action_type": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_.]{0,99}$"
    },
    "complete": {
      "type": "boolean"
    },
    "rows": {
      "maxItems": 500,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "account_id": {
            "type": "string",
            "pattern": "^[1-9]\\d{1,24}$"
          },
          "account_currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "campaign_id": {
            "type": "string",
            "pattern": "^[1-9]\\d{1,24}$"
          },
          "campaign_name": {
            "type": "string",
            "maxLength": 200
          },
          "adset_id": {
            "type": "string",
            "pattern": "^[1-9]\\d{1,24}$"
          },
          "ad_id": {
            "type": "string",
            "pattern": "^[1-9]\\d{1,24}$"
          },
          "date_start": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "date_stop": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "spend": {
            "type": "string",
            "pattern": "^\\d{1,12}(?:\\.\\d{1,6})?$"
          },
          "clicks": {
            "type": "string",
            "pattern": "^\\d{1,15}$"
          },
          "actions": {
            "maxItems": 100,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "action_type": {
                  "type": "string",
                  "pattern": "^[a-z][a-z0-9_.]{0,99}$"
                },
                "value": {
                  "type": "string",
                  "pattern": "^\\d{1,12}(?:\\.\\d{1,6})?$"
                },
                "1d_click": {
                  "type": "string",
                  "pattern": "^\\d{1,12}(?:\\.\\d{1,6})?$"
                },
                "7d_click": {
                  "type": "string",
                  "pattern": "^\\d{1,12}(?:\\.\\d{1,6})?$"
                },
                "1d_view": {
                  "type": "string",
                  "pattern": "^\\d{1,12}(?:\\.\\d{1,6})?$"
                }
              },
              "required": [
                "action_type"
              ],
              "additionalProperties": false
            }
          },
          "action_values": {
            "maxItems": 100,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "action_type": {
                  "type": "string",
                  "pattern": "^[a-z][a-z0-9_.]{0,99}$"
                },
                "value": {
                  "type": "string",
                  "pattern": "^\\d{1,12}(?:\\.\\d{1,6})?$"
                },
                "1d_click": {
                  "type": "string",
                  "pattern": "^\\d{1,12}(?:\\.\\d{1,6})?$"
                },
                "7d_click": {
                  "type": "string",
                  "pattern": "^\\d{1,12}(?:\\.\\d{1,6})?$"
                },
                "1d_view": {
                  "type": "string",
                  "pattern": "^\\d{1,12}(?:\\.\\d{1,6})?$"
                }
              },
              "required": [
                "action_type"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "account_id",
          "account_currency",
          "campaign_id",
          "date_start",
          "date_stop"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "workspace_id",
    "source_kind",
    "source_id",
    "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",
    "rows"
  ],
  "additionalProperties": false
}
```

## 回應與完成

成功 HTTP 狀態：200

成功 HTTP 回應可能表示請求已接受，並非已完成。背景工作請儲存回傳 ID，持續檢查同一操作直到完成。已排程或已接受的貼文，只有平台確認後才算已發布；用戶端逾時無法證明結果。

```json
{
  "$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"
        ]
      }
    }
  },
  "required": [
    "contract_version",
    "source_id",
    "source_sha256",
    "identity_verification",
    "currency",
    "timezone",
    "selection",
    "complete",
    "rows",
    "totals",
    "gaps",
    "suggestions"
  ]
}
```

## 錯誤與安全重試

檢查 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

```json
{
  "workspace_id": "11111111-1111-4111-8111-111111111111",
  "source_kind": "customer_import",
  "source_id": "example",
  "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": []
}
```

cURL

```bash
curl --request POST \
  "https://gqeshlawtcexsapabaui.supabase.co/functions/v1/advertising-api/performance/analyze" \
  -H "Authorization: Bearer $SOSOAPI_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  --data-binary @request.json
```

JavaScript

```js
// 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/performance/analyze", {
  method: "POST",
  headers: { "Content-Type": "application/json", Authorization: "Bearer " + token },
  body: JSON.stringify({
  "workspace_id": "11111111-1111-4111-8111-111111111111",
  "source_kind": "customer_import",
  "source_id": "example",
  "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": []
})
});
const result = await response.json();
// Check response.ok, the operation-specific body and completion state before continuing.
```

CLI

```bash
npx sosoapi api post /advertising-api/performance/analyze < request.json
```

合成回應範例

```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": []
}
```

## 相關工具與指南

MCP: sosoapi_ads_performance_analyze

[API 參考](https://sosoapi.ai/zh-tw/docs/api)
