# 預覽已對應的報表範本欄位

標準 URL： https://sosoapi.ai/zh-tw/docs/mcp/preview-report-template

`sosoapi_preview_report_template`

預覽已對應的報表範本欄位。使用明確指定且已審閱的資料集與版本；不會自動更新資料來源。 可透過管線將渲染輸入傳給 sosoapi report render --output FILE。

## 設定與傳輸方式

設定：full

傳輸方式：stdio、http

選擇 core 或 full 以控制用戶端顯示的工具；這不會變更權限。本機檔案上傳需要 stdio，無法透過 HTTP 使用。設定 SOSOAPI_OUTPUT_SCHEMAS=1 可在探索結果加入輸出結構描述。無論是否啟用此設定，工具皆會回傳結構化結果。

## 權限與副作用

註解幫助用戶端描述工具。每次呼叫仍會檢查使用者身分驗證、角色、資源存取和能力授權。

```json
{
  "readOnlyHint": true,
  "destructiveHint": false,
  "idempotentHint": true,
  "openWorldHint": true
}
```

`/analytics-api/reporting/templates/preview` — agent:operate；synchronous_http_response

## 輸入欄位

```json
{
  "type": "object",
  "properties": {
    "workspace_id": {
      "type": "string",
      "format": "uuid"
    },
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "version": {
      "type": "integer",
      "minimum": 1,
      "maximum": 1000000
    },
    "dataset": {
      "type": "object",
      "properties": {
        "contractVersion": {
          "type": "string",
          "enum": [
            "analytics-report/v1"
          ]
        },
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "reviewedAt": {
          "type": "string",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
          "format": "date-time"
        },
        "selection": {
          "type": "object",
          "properties": {
            "workspaceId": {
              "type": "string",
              "format": "uuid"
            },
            "accountIds": {
              "minItems": 1,
              "maxItems": 50,
              "type": "array",
              "items": {
                "type": "string",
                "format": "uuid"
              }
            },
            "platforms": {
              "minItems": 1,
              "maxItems": 4,
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "facebook",
                  "instagram",
                  "threads",
                  "youtube"
                ]
              }
            },
            "startDate": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            },
            "endDate": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            },
            "timezone": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            }
          },
          "required": [
            "workspaceId",
            "accountIds",
            "platforms",
            "startDate",
            "endDate",
            "timezone"
          ],
          "additionalProperties": false
        },
        "accounts": {
          "maxItems": 50,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "workspaceId": {
                "type": "string",
                "format": "uuid"
              },
              "platform": {
                "type": "string",
                "enum": [
                  "facebook",
                  "instagram",
                  "threads",
                  "youtube"
                ]
              },
              "name": {
                "type": "string",
                "maxLength": 500
              },
              "connectionStatus": {
                "type": "string",
                "maxLength": 100
              },
              "healthMessage": {
                "type": "string",
                "maxLength": 1000
              }
            },
            "required": [
              "id",
              "workspaceId",
              "platform",
              "name"
            ],
            "additionalProperties": false
          }
        },
        "posts": {
          "maxItems": 1000,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "social_post_id": {
                "type": "string",
                "format": "uuid"
              },
              "workspace_id": {
                "type": "string",
                "format": "uuid"
              },
              "social_account_id": {
                "type": "string",
                "format": "uuid"
              },
              "platform": {
                "type": "string",
                "enum": [
                  "instagram",
                  "facebook",
                  "threads",
                  "youtube"
                ]
              },
              "provider_post_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 512
              },
              "provider_published_at": {
                "anyOf": [
                  {
                    "type": "string",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
                    "format": "date-time"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "content_format": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "permalink": {
                "anyOf": [
                  {
                    "type": "string",
                    "maxLength": 2048,
                    "format": "uri"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "provider_state": {
                "type": "string",
                "enum": [
                  "available",
                  "deleted",
                  "unavailable",
                  "unknown"
                ]
              },
              "first_seen_at": {
                "type": "string",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
                "format": "date-time"
              },
              "last_seen_at": {
                "type": "string",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
                "format": "date-time"
              },
              "scheduled_post_id": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "uuid"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "provenance": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string",
                    "enum": [
                      "instagram",
                      "facebook",
                      "threads",
                      "youtube"
                    ]
                  },
                  "source": {
                    "type": "string",
                    "enum": [
                      "provider_api",
                      "provider_webhook",
                      "publication_outcome",
                      "backfill"
                    ]
                  },
                  "source_job_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "provider_api_version": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "schema_version": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "provider",
                  "source",
                  "source_job_id",
                  "provider_api_version",
                  "schema_version"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "social_post_id",
              "workspace_id",
              "social_account_id",
              "platform",
              "provider_post_id",
              "provider_published_at",
              "content_format",
              "permalink",
              "provider_state",
              "first_seen_at",
              "last_seen_at",
              "scheduled_post_id",
              "provenance"
            ],
            "additionalProperties": false
          }
        },
        "sources": {
          "maxItems": 30,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "accountId": {
                "type": "string",
                "format": "uuid"
              },
              "platform": {
                "type": "string",
                "enum": [
                  "facebook",
                  "instagram",
                  "threads",
                  "youtube"
                ]
              },
              "resourceKind": {
                "type": "string",
                "enum": [
                  "account",
                  "post"
                ]
              },
              "providerResourceId": {
                "anyOf": [
                  {
                    "type": "string",
                    "maxLength": 512
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "requestId": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "uuid"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "status": {
                "type": "string",
                "enum": [
                  "available",
                  "partial",
                  "not_returned",
                  "unsupported",
                  "permission_required",
                  "threshold_not_met",
                  "no_data",
                  "failed",
                  "pending",
                  "stale"
                ]
              },
              "reason": {
                "anyOf": [
                  {
                    "type": "string",
                    "maxLength": 8000
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "envelope": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "contract_version": {
                        "type": "string",
                        "enum": [
                          "provider-insights/v1"
                        ]
                      },
                      "request_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "platform": {
                        "type": "string",
                        "enum": [
                          "facebook",
                          "instagram",
                          "threads",
                          "youtube"
                        ]
                      },
                      "resource": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "account",
                              "post"
                            ]
                          },
                          "social_account_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "provider_resource_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "kind",
                          "social_account_id",
                          "provider_resource_id"
                        ],
                        "additionalProperties": false
                      },
                      "provider_api_version": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100
                      },
                      "fetched_at": {
                        "type": "string",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
                        "format": "date-time"
                      },
                      "status": {
                        "type": "string",
                        "enum": [
                          "available",
                          "partial",
                          "unavailable"
                        ]
                      },
                      "availability": {
                        "minItems": 1,
                        "maxItems": 64,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "scope": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 200
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "available",
                                "partial",
                                "not_returned",
                                "unsupported",
                                "permission_required",
                                "threshold_not_met",
                                "no_data",
                                "failed"
                              ]
                            },
                            "reason": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 2000
                            },
                            "diagnostics": {
                              "type": "object",
                              "properties": {
                                "http_status": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 599
                                },
                                "failed_step": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 200
                                },
                                "provider_code": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "string",
                                      "maxLength": 100
                                    }
                                  ]
                                },
                                "provider_subcode": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "string",
                                      "maxLength": 100
                                    }
                                  ]
                                },
                                "provider_type": {
                                  "type": "string",
                                  "maxLength": 200
                                },
                                "is_transient": {
                                  "type": "boolean"
                                },
                                "provider_request_id": {
                                  "type": "string",
                                  "maxLength": 200
                                },
                                "access": {
                                  "type": "object",
                                  "properties": {
                                    "login_mode": {
                                      "type": "string",
                                      "enum": [
                                        "instagram_login",
                                        "facebook_login",
                                        "threads_user"
                                      ]
                                    },
                                    "provider_host": {
                                      "type": "string",
                                      "maxLength": 200
                                    },
                                    "required_permissions": {
                                      "maxItems": 16,
                                      "type": "array",
                                      "items": {
                                        "type": "string",
                                        "maxLength": 100
                                      }
                                    },
                                    "current_connection_policy_permissions": {
                                      "maxItems": 16,
                                      "type": "array",
                                      "items": {
                                        "type": "string",
                                        "maxLength": 100
                                      }
                                    },
                                    "granted_permissions": {
                                      "anyOf": [
                                        {
                                          "maxItems": 128,
                                          "type": "array",
                                          "items": {
                                            "type": "string",
                                            "maxLength": 100
                                          }
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ]
                                    },
                                    "grant_evidence": {
                                      "type": "string",
                                      "enum": [
                                        "exact",
                                        "unknown"
                                      ]
                                    },
                                    "permission_state": {
                                      "type": "string",
                                      "enum": [
                                        "granted",
                                        "missing",
                                        "unknown"
                                      ]
                                    },
                                    "grant_observed_at": {
                                      "type": "string",
                                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
                                      "format": "date-time"
                                    },
                                    "app_access": {
                                      "type": "string",
                                      "enum": [
                                        "unverified"
                                      ]
                                    },
                                    "next_step": {
                                      "type": "string",
                                      "maxLength": 1500
                                    }
                                  },
                                  "required": [
                                    "login_mode",
                                    "provider_host",
                                    "required_permissions",
                                    "current_connection_policy_permissions",
                                    "granted_permissions",
                                    "grant_evidence",
                                    "permission_state",
                                    "app_access",
                                    "next_step"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "http_status"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "scope",
                            "status"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "provider_data": {
                        "anyOf": [
                          {},
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "requested_date_range": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "start_date": {
                                "type": "string",
                                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                              },
                              "end_date": {
                                "type": "string",
                                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                              }
                            },
                            "required": [
                              "start_date",
                              "end_date"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "cache": {
                        "type": "object",
                        "properties": {
                          "authoritative": {
                            "type": "boolean",
                            "enum": [
                              false
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "stored",
                              "hit",
                              "bypassed"
                            ]
                          },
                          "expires_at": {
                            "type": "string",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "authoritative",
                          "status",
                          "expires_at"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "contract_version",
                      "request_id",
                      "platform",
                      "resource",
                      "provider_api_version",
                      "fetched_at",
                      "status",
                      "availability",
                      "provider_data",
                      "requested_date_range",
                      "cache"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "metrics": {
                "maxItems": 5000,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 150
                    },
                    "definition": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 1000
                    },
                    "unit": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 100
                    },
                    "grain": {
                      "type": "string",
                      "enum": [
                        "post",
                        "account"
                      ]
                    },
                    "value": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "availability": {
                      "type": "string",
                      "enum": [
                        "available",
                        "partial",
                        "not_returned",
                        "unsupported",
                        "permission_required",
                        "threshold_not_met",
                        "no_data",
                        "failed",
                        "pending",
                        "stale"
                      ]
                    },
                    "reason": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 4000
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "measurement": {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "enum": [
                            "lifetime",
                            "snapshot",
                            "period",
                            "unknown"
                          ]
                        },
                        "period": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 100
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "start": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 100
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "end": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 100
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "timezone": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 100
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "kind",
                        "period",
                        "start",
                        "end",
                        "timezone"
                      ],
                      "additionalProperties": false
                    },
                    "sourcePath": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 2000
                    }
                  },
                  "required": [
                    "key",
                    "definition",
                    "unit",
                    "grain",
                    "value",
                    "availability",
                    "reason",
                    "measurement",
                    "sourcePath"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "accountId",
              "platform",
              "resourceKind",
              "providerResourceId",
              "requestId",
              "status",
              "reason",
              "envelope",
              "metrics"
            ],
            "additionalProperties": false
          }
        },
        "coverage": {
          "type": "object",
          "properties": {
            "population": {
              "type": "string",
              "enum": [
                "discovered_posts"
              ]
            },
            "postsComplete": {
              "type": "boolean"
            },
            "nextCursor": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 16384
                },
                {
                  "type": "null"
                }
              ]
            },
            "postLimit": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000
            },
            "postInsightsLimit": {
              "type": "integer",
              "minimum": 0,
              "maximum": 20
            },
            "omittedPostInsights": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "notes": {
              "maxItems": 50,
              "type": "array",
              "items": {
                "type": "string",
                "maxLength": 2000
              }
            }
          },
          "required": [
            "population",
            "postsComplete",
            "nextCursor",
            "postLimit",
            "postInsightsLimit",
            "omittedPostInsights",
            "notes"
          ],
          "additionalProperties": false
        },
        "customMetrics": {
          "maxItems": 50,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "version": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              "expression": {
                "type": "string",
                "minLength": 1,
                "maxLength": 1000
              },
              "definition": {
                "type": "string",
                "maxLength": 1000
              },
              "unit": {
                "type": "string",
                "maxLength": 100
              },
              "grain": {
                "type": "string",
                "enum": [
                  "post",
                  "account",
                  "compatible_sum"
                ]
              },
              "rounding": {
                "type": "object",
                "properties": {
                  "decimalPlaces": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 8
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "half_away_from_zero"
                    ]
                  }
                },
                "required": [
                  "decimalPlaces",
                  "mode"
                ],
                "additionalProperties": false
              },
              "inputs": {
                "maxItems": 5000,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "requestId": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "uuid"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "sourcePath": {
                      "type": "string",
                      "maxLength": 2000
                    },
                    "value": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "availability": {
                      "type": "string",
                      "enum": [
                        "available",
                        "partial",
                        "not_returned",
                        "unsupported",
                        "permission_required",
                        "threshold_not_met",
                        "no_data",
                        "failed",
                        "pending",
                        "stale"
                      ]
                    }
                  },
                  "required": [
                    "requestId",
                    "sourcePath",
                    "value",
                    "availability"
                  ],
                  "additionalProperties": false
                }
              },
              "value": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "availability": {
                "type": "string",
                "enum": [
                  "available",
                  "partial",
                  "not_returned",
                  "unsupported",
                  "permission_required",
                  "threshold_not_met",
                  "no_data",
                  "failed",
                  "pending",
                  "stale"
                ]
              },
              "reason": {
                "anyOf": [
                  {
                    "type": "string",
                    "maxLength": 4000
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "formula": {
                "type": "object",
                "properties": {
                  "contractVersion": {
                    "type": "string",
                    "enum": [
                      "analytics-metric/v1"
                    ]
                  },
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "workspaceId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "version": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000000
                  },
                  "expression": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  },
                  "fields": {
                    "maxItems": 32,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "identifier": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9_]{0,63}$"
                        },
                        "selector": {
                          "type": "object",
                          "properties": {
                            "platform": {
                              "type": "string",
                              "enum": [
                                "facebook",
                                "instagram",
                                "threads",
                                "youtube"
                              ]
                            },
                            "key": {
                              "type": "string",
                              "pattern": "^[A-Za-z][A-Za-z0-9_]{0,100}$"
                            },
                            "definition": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 500
                            },
                            "unit": {
                              "type": "string",
                              "enum": [
                                "count",
                                "seconds",
                                "minutes",
                                "percent",
                                "ratio"
                              ]
                            },
                            "grain": {
                              "type": "string",
                              "enum": [
                                "post",
                                "account"
                              ]
                            },
                            "measurementKind": {
                              "type": "string",
                              "enum": [
                                "lifetime",
                                "snapshot",
                                "period",
                                "unknown"
                              ]
                            },
                            "nativePeriod": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 64
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "timezone": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 100
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "platform",
                            "key",
                            "definition",
                            "unit",
                            "grain",
                            "measurementKind",
                            "nativePeriod",
                            "timezone"
                          ],
                          "additionalProperties": false
                        },
                        "aggregation": {
                          "type": "string",
                          "enum": [
                            "single",
                            "sum"
                          ]
                        }
                      },
                      "required": [
                        "identifier",
                        "selector",
                        "aggregation"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "rounding": {
                    "type": "object",
                    "properties": {
                      "decimalPlaces": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 8
                      },
                      "mode": {
                        "type": "string",
                        "enum": [
                          "half_away_from_zero"
                        ]
                      }
                    },
                    "required": [
                      "decimalPlaces",
                      "mode"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "contractVersion",
                  "id",
                  "workspaceId",
                  "name",
                  "version",
                  "expression",
                  "fields",
                  "rounding"
                ],
                "additionalProperties": false
              },
              "calculation": {
                "type": "object",
                "properties": {
                  "contractVersion": {
                    "type": "string",
                    "enum": [
                      "analytics-metric/v1"
                    ]
                  },
                  "workspaceId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "datasetId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "formulaId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "version": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "expression": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "rounding": {
                    "type": "object",
                    "properties": {
                      "decimalPlaces": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 8
                      },
                      "mode": {
                        "type": "string",
                        "enum": [
                          "half_away_from_zero"
                        ]
                      }
                    },
                    "required": [
                      "decimalPlaces",
                      "mode"
                    ],
                    "additionalProperties": false
                  },
                  "value": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "unit": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "available",
                      "not_returned"
                    ]
                  },
                  "code": {
                    "type": "string",
                    "enum": [
                      "ok",
                      "invalid_expression",
                      "missing_input",
                      "incompatible_input",
                      "zero_denominator",
                      "numeric_limit",
                      "workspace_mismatch",
                      "ambiguous_input",
                      "unknown_exclusion"
                    ]
                  },
                  "reason": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "excludedInputIds": {
                    "maxItems": 5000,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 1500
                    }
                  },
                  "inputs": {
                    "maxItems": 5000,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "inputId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 1500
                        },
                        "selector": {
                          "type": "object",
                          "properties": {
                            "platform": {
                              "type": "string",
                              "enum": [
                                "facebook",
                                "instagram",
                                "threads",
                                "youtube"
                              ]
                            },
                            "key": {
                              "type": "string",
                              "pattern": "^[A-Za-z][A-Za-z0-9_]{0,100}$"
                            },
                            "definition": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 500
                            },
                            "unit": {
                              "type": "string",
                              "enum": [
                                "count",
                                "seconds",
                                "minutes",
                                "percent",
                                "ratio"
                              ]
                            },
                            "grain": {
                              "type": "string",
                              "enum": [
                                "post",
                                "account"
                              ]
                            },
                            "measurementKind": {
                              "type": "string",
                              "enum": [
                                "lifetime",
                                "snapshot",
                                "period",
                                "unknown"
                              ]
                            },
                            "nativePeriod": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 64
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "timezone": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 100
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "platform",
                            "key",
                            "definition",
                            "unit",
                            "grain",
                            "measurementKind",
                            "nativePeriod",
                            "timezone"
                          ],
                          "additionalProperties": false
                        },
                        "value": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "availability": {
                          "type": "string",
                          "enum": [
                            "available",
                            "partial",
                            "not_returned",
                            "unsupported",
                            "permission_required",
                            "threshold_not_met",
                            "no_data",
                            "failed",
                            "pending",
                            "stale"
                          ]
                        },
                        "reason": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 8000
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "measurement": {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "enum": [
                                "lifetime",
                                "snapshot",
                                "period",
                                "unknown"
                              ]
                            },
                            "period": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 64
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "start": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 64
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "end": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 64
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "timezone": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 100
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "kind",
                            "period",
                            "start",
                            "end",
                            "timezone"
                          ],
                          "additionalProperties": false
                        },
                        "requestId": {
                          "anyOf": [
                            {
                              "type": "string",
                              "format": "uuid"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "sourcePath": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 1000
                        },
                        "accountId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "providerResourceId": {
                          "anyOf": [
                            {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 512
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "fetchedAt": {
                          "anyOf": [
                            {
                              "type": "string",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
                              "format": "date-time"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "identifier": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9_]{0,63}$"
                        },
                        "included": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "inputId",
                        "selector",
                        "value",
                        "availability",
                        "reason",
                        "measurement",
                        "requestId",
                        "sourcePath",
                        "accountId",
                        "providerResourceId",
                        "fetchedAt",
                        "identifier",
                        "included"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "contractVersion",
                  "workspaceId",
                  "datasetId",
                  "formulaId",
                  "name",
                  "version",
                  "expression",
                  "rounding",
                  "value",
                  "unit",
                  "status",
                  "code",
                  "reason",
                  "excludedInputIds",
                  "inputs"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "id",
              "name",
              "version",
              "expression",
              "definition",
              "unit",
              "grain",
              "rounding",
              "inputs",
              "value",
              "availability",
              "reason"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "contractVersion",
        "id",
        "reviewedAt",
        "selection",
        "accounts",
        "posts",
        "sources",
        "coverage",
        "customMetrics"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "workspace_id",
    "id",
    "version",
    "dataset"
  ],
  "additionalProperties": false
}
```

## 結構化輸出

此 schema 描述成功工具結果中的 structuredContent。MCP 回應也包含 content，並可能在呼叫失敗時設定 isError。對於發布，請讀取貼文的最終結果，不要把已接受的請求或文字回應當作確認。連結的 API 操作說明了權限和重試規則。

```json
{
  "type": "object",
  "properties": {
    "datasetId": {
      "type": "string",
      "format": "uuid"
    },
    "sourceSha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "fingerprint": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "values": {
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 64
          },
          "required": {
            "type": "boolean"
          },
          "kind": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "text",
                  "selection",
                  "metric",
                  "formula",
                  "table",
                  "chart"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "text": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "resolved",
              "missing",
              "unavailable"
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "chart": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                },
                "value": {
                  "type": "number"
                }
              },
              "required": [
                "label",
                "value"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "name",
          "required",
          "kind",
          "text",
          "status",
          "reason"
        ],
        "additionalProperties": false
      }
    },
    "blocking": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "datasetId",
    "sourceSha256",
    "fingerprint",
    "values",
    "blocking",
    "warnings"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false
}
```

## 工具呼叫範例

這些範例使用已依結構描述檢查的虛構值。請將 ID 替換為您有權使用的 ID、將媒體替換為已就緒素材，並將日期替換為已確認的發布時間。提交寫入前，請檢查帳號資格。本頁不會傳送 API 請求。

```json
{
  "name": "sosoapi_preview_report_template",
  "arguments": {
    "workspace_id": "11111111-1111-4111-8111-111111111111",
    "id": "11111111-1111-4111-8111-111111111111",
    "version": 1,
    "dataset": {
      "contractVersion": "analytics-report/v1",
      "id": "11111111-1111-4111-8111-111111111111",
      "reviewedAt": "2099-01-15T09:00:00Z",
      "selection": {
        "workspaceId": "11111111-1111-4111-8111-111111111111",
        "accountIds": [
          "11111111-1111-4111-8111-111111111111"
        ],
        "platforms": [
          "facebook"
        ],
        "startDate": "2099-01-15",
        "endDate": "2099-01-15",
        "timezone": "UTC"
      },
      "accounts": [
        {
          "id": "11111111-1111-4111-8111-111111111111",
          "workspaceId": "11111111-1111-4111-8111-111111111111",
          "platform": "facebook",
          "name": "Fictional report account"
        }
      ],
      "posts": [],
      "sources": [],
      "coverage": {
        "population": "discovered_posts",
        "postsComplete": false,
        "nextCursor": null,
        "postLimit": 0,
        "postInsightsLimit": 0,
        "omittedPostInsights": 0,
        "notes": []
      },
      "customMetrics": []
    }
  }
}
```

structuredContent

```json
{
  "datasetId": "11111111-1111-4111-8111-111111111111",
  "sourceSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "fingerprint": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "values": [],
  "blocking": [],
  "warnings": []
}
```

## 底層 API 操作

- [/analytics-api/reporting/templates/preview](https://sosoapi.ai/zh-tw/docs/api/analytics-api-reporting-templates-preview)
