{"id":"831f182d-7764-4920-b334-c6b7d5572b82","entityType":"agent","slug":"clawhub-linkfox-ai-linkfox-amazon-ads-report","name":"亚马逊-广告报表","canonicalUrl":"https://www.xpersona.co/agent/clawhub-linkfox-ai-linkfox-amazon-ads-report","canonicalPath":"/agent/clawhub-linkfox-ai-linkfox-amazon-ads-report","generatedAt":"2026-10-10T05:39:55.755Z","source":"CLAWHUB","claimStatus":"UNCLAIMED","verificationTier":"NONE","summary":{"evidence":{"source":"editorial-content","verified":true,"confidence":"high","updatedAt":"2026-10-10T02:58:23.782Z","emptyReason":null},"description":"亚马逊广告（Amazon Ads）报告一站式获取技能，覆盖 Sponsored Products (SP) / Sponsored Brands (SB) / Sponsored Display (SD) 全部报告类型。脚本自动完成报告的创建、等待、下载和解压，直接返回可读的结构化数据。真实可用的报告类型及每类的列清单/groupBy/filters 以 `references/report-types/{adProduct-dir}/{reportTypeId}.md` 为单一真相源。当用户提到拉取亚马逊广告报告、下载 Amazon Ads 报告、获取 SP/SB/SD 广告活动/关键词/搜索词/投放商品/购买商品/广告组/流量异常/Prompt 扩展等任意报告时触发。本技能依赖 linkfox-amazon-ads-auth。Sponsored Television (ST) / Amazon DSP 暂未覆盖。 Skill: 亚马逊-广告报表 Owner: linkfox-ai Summary: 亚马逊广告（Amazon Ads）报告一站式获取技能，覆盖 Sponsored Products (SP) / Sponsored Brands (SB) / Sponsored Display (SD) 全部报告类型。脚本自动完成报告的创建、等待、下载和解压，直接返回可读的结构化数据。真实可用的报告类型及每类的列清单/groupBy/filters 以 references/report-types/{adProduct-dir}/{reportTypeId}.md 为单一真相源。当用户提到拉取亚马逊广告报告、下载 Amazon Ads 报告、获取 SP/SB/SD 广告活动/关键词/搜索词/投放商品/购买商品/广告组/流量异常/Prompt 扩展等任意报告时触发。本技能依赖 linkfox-amazon-ads-auth。Sponsored","descriptionLabel":"Technical summary","evidenceSummary":"Capability contract not published. No trust telemetry is available yet. 1.8K downloads reported by the source. Last updated 10/10/2026.","installCommand":"clawhub skill install s171g8b6m2khwdy9ye8bxj0wx183vd4z:linkfox-amazon-ads-report","sourceUrl":"https://clawhub.ai/linkfox-ai/linkfox-amazon-ads-report","homepage":"https://clawhub.ai/linkfox-ai/skills/linkfox-amazon-ads-report","primaryLinks":[{"label":"View on ClawHub","url":"https://clawhub.ai/linkfox-ai/linkfox-amazon-ads-report","kind":"source"},{"label":"Homepage","url":"https://clawhub.ai/linkfox-ai/skills/linkfox-amazon-ads-report","kind":"homepage"}],"safetyScore":84,"overallRank":62,"popularityScore":65,"trustScore":null,"claimedByName":null,"isOwner":false,"seoDescription":"亚马逊广告（Amazon Ads）报告一站式获取技能，覆盖 Sponsored Products (SP) / Sponsored Brands (SB) / Sponsored Display (SD) 全部报告类型。脚本自动完成报告的创建、等待、下载和解压，直接返回可读的结构化数据。真实可用的报告类型及每类的列清单"},"coverage":{"evidence":{"source":"public-profile","verified":false,"confidence":"medium","updatedAt":"2026-10-10T02:58:23.782Z","emptyReason":null},"protocols":[{"protocol":"OPENCLEW","label":"OpenClaw","status":"self-declared","notes":"Declared in the public agent profile."}],"capabilities":[],"verifiedCount":0,"selfDeclaredCount":1,"capabilityMatrix":{"rows":[{"key":"OPENCLEW","type":"protocol","support":"unknown","confidenceSource":"profile","notes":"Listed on profile"}],"flattenedTokens":"protocol:OPENCLEW|unknown|profile"}},"adoption":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-10T02:58:23.782Z","emptyReason":null},"stars":null,"forks":null,"downloads":1752,"packageName":null,"latestVersion":"1.0.8","tractionLabel":"1.8K downloads"},"release":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-10T02:58:23.782Z","emptyReason":null},"lastUpdatedAt":"2026-10-10T02:58:23.782Z","lastCrawledAt":"2026-10-10T02:58:23.782Z","lastIndexedAt":null,"nextCrawlAt":"2026-10-11T02:58:23.782Z","lastVerifiedAt":null,"highlights":[{"version":"1.0.8","createdAt":"2026-09-14T04:54:14.458Z","changelog":"Update from 1.0.7 to 1.0.8","fileCount":34,"zipByteSize":73142},{"version":"1.0.7","createdAt":"2026-08-14T14:42:35.338Z","changelog":"Update from 1.0.6 to 1.0.7","fileCount":34,"zipByteSize":72142},{"version":"1.0.6","createdAt":"2026-08-07T10:39:09.974Z","changelog":"Update from 1.0.5 to 1.0.6","fileCount":34,"zipByteSize":72105},{"version":"1.0.5","createdAt":"2026-07-13T12:02:24.998Z","changelog":"Update from 1.0.4 to 1.0.5","fileCount":32,"zipByteSize":63056},{"version":"1.0.4","createdAt":"2026-07-06T11:10:00.353Z","changelog":"Update from 1.0.3 to 1.0.4","fileCount":32,"zipByteSize":62400},{"version":"1.0.3","createdAt":"2026-07-03T08:09:28.142Z","changelog":"Update from 1.0.2 to 1.0.3","fileCount":31,"zipByteSize":61179},{"version":"1.0.2","createdAt":"2026-07-03T04:34:17.048Z","changelog":"Update from 1.0.1 to 1.0.2","fileCount":31,"zipByteSize":61169},{"version":"1.0.1","createdAt":"2026-05-14T12:34:18.455Z","changelog":"Update from 0.0.1 to 1.0.1","fileCount":32,"zipByteSize":59824}]},"execution":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No published capability contract is available yet."},"installCommand":"clawhub skill install s171g8b6m2khwdy9ye8bxj0wx183vd4z:linkfox-amazon-ads-report","setupComplexity":"low","setupSteps":["Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.","Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data."],"contract":{"contractStatus":"missing","authModes":[],"requires":[],"forbidden":[],"supportsMcp":false,"supportsA2a":false,"supportsStreaming":false,"inputSchemaRef":null,"outputSchemaRef":null,"dataRegion":null,"contractUpdatedAt":null,"sourceUpdatedAt":null,"freshnessSeconds":null},"invocationGuide":{"preferredApi":{"snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-linkfox-ai-linkfox-amazon-ads-report/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-linkfox-ai-linkfox-amazon-ads-report/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-linkfox-ai-linkfox-amazon-ads-report/trust"},"curlExamples":["curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-linkfox-ai-linkfox-amazon-ads-report/snapshot\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-linkfox-ai-linkfox-amazon-ads-report/contract\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-linkfox-ai-linkfox-amazon-ads-report/trust\""],"jsonRequestTemplate":{"query":"summarize this repo","constraints":{"maxLatencyMs":2000,"protocolPreference":["OPENCLEW"]}},"jsonResponseTemplate":{"ok":true,"result":{"summary":"...","confidence":0.9},"meta":{"source":"CLAWHUB","generatedAt":"2026-10-10T05:39:55.751Z"}},"retryPolicy":{"maxAttempts":3,"backoffMs":[500,1500,3500],"retryableConditions":["HTTP_429","HTTP_503","NETWORK_TIMEOUT"]}},"endpoints":{"dossierUrl":"https://www.xpersona.co/api/v1/agents/clawhub-linkfox-ai-linkfox-amazon-ads-report/dossier","snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-linkfox-ai-linkfox-amazon-ads-report/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-linkfox-ai-linkfox-amazon-ads-report/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-linkfox-ai-linkfox-amazon-ads-report/trust"}},"reliability":{"evidence":{"source":"runtime-metrics","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No trust, reliability, or runtime telemetry is available."},"trust":{"status":"unavailable","handshakeStatus":"UNKNOWN","verificationFreshnessHours":null,"reputationScore":null,"p95LatencyMs":null,"successRate30d":null,"fallbackRate":null,"attempts30d":null,"trustUpdatedAt":null,"trustConfidence":"unknown","sourceUpdatedAt":null,"freshnessSeconds":null},"decisionGuardrails":{"doNotUseIf":["Contract metadata is missing or unavailable for deterministic execution."],"safeUseWhen":[],"riskFlags":["missing_or_unavailable_contract","trust_data_unavailable","schema_references_missing"],"operationalConfidence":"low"},"executionMetrics":{"observedLatencyMsP50":null,"observedLatencyMsP95":null,"estimatedCostUsd":null,"uptime30d":null,"rateLimitRpm":null,"rateLimitBurst":null,"lastVerifiedAt":null,"verificationSource":null},"runtimeMetrics":{"successRate":null,"avgLatencyMs":null,"avgCostUsd":null,"hallucinationRate":null,"retryRate":null,"disputeRate":null,"p50Latency":null,"p95Latency":null,"lastUpdated":null}},"benchmarks":{"evidence":{"source":"no-benchmark-data","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No benchmark suites or observed failure patterns are available."},"suites":[],"failurePatterns":[]},"artifacts":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"high","updatedAt":"2026-10-10T02:58:23.782Z","emptyReason":null},"readme":"Skill: 亚马逊-广告报表\n\nOwner: linkfox-ai\n\nSummary: 亚马逊广告（Amazon Ads）报告一站式获取技能，覆盖 Sponsored Products (SP) / Sponsored Brands (SB) / Sponsored Display (SD) 全部报告类型。脚本自动完成报告的创建、等待、下载和解压，直接返回可读的结构化数据。真实可用的报告类型及每类的列清单/groupBy/filters 以 `references/report-types/{adProduct-dir}/{reportTypeId}.md` 为单一真相源。当用户提到拉取亚马逊广告报告、下载 Amazon Ads 报告、获取 SP/SB/SD 广告活动/关键词/搜索词/投放商品/购买商品/广告组/流量异常/Prompt 扩展等任意报告时触发。本技能依赖 linkfox-amazon-ads-auth。Sponsored Television (ST) / Amazon DSP 暂未覆盖。\n\nTags: latest:1.0.8\n\nVersion history:\n\nv1.0.8 | 2026-09-14T04:54:14.458Z | user\n\nUpdate from 1.0.7 to 1.0.8\n\nv1.0.7 | 2026-08-14T14:42:35.338Z | user\n\nUpdate from 1.0.6 to 1.0.7\n\nv1.0.6 | 2026-08-07T10:39:09.974Z | user\n\nUpdate from 1.0.5 to 1.0.6\n\nv1.0.5 | 2026-07-13T12:02:24.998Z | user\n\nUpdate from 1.0.4 to 1.0.5\n\nv1.0.4 | 2026-07-06T11:10:00.353Z | user\n\nUpdate from 1.0.3 to 1.0.4\n\nv1.0.3 | 2026-07-03T08:09:28.142Z | user\n\nUpdate from 1.0.2 to 1.0.3\n\nv1.0.2 | 2026-07-03T04:34:17.048Z | user\n\nUpdate from 1.0.1 to 1.0.2\n\nv1.0.1 | 2026-05-14T12:34:18.455Z | user\n\nUpdate from 0.0.1 to 1.0.1\n\nv0.0.1 | 2026-05-07T11:42:21.168Z | user\n\nInitial release\n\nArchive index:\n\nArchive v1.0.8: 34 files, 73142 bytes\n\nFiles: references/api.md (10763b), references/onboarding.md (1999b), references/report-types/index.md (552b), references/report-types/sb/index.md (562b), references/report-types/sb/sbAdGroup.md (4001b), references/report-types/sb/sbAds.md (3314b), references/report-types/sb/sbCampaignPlacement.md (3673b), references/report-types/sb/sbCampaigns.md (4286b), references/report-types/sb/sbGrossAndInvalids.md (1786b), references/report-types/sb/sbPromptAdExtension.md (4170b), references/report-types/sb/sbPurchasedProduct.md (2262b), references/report-types/sb/sbSearchTerm.md (3788b), references/report-types/sb/sbTargeting.md (4330b), references/report-types/sd/index.md (426b), references/report-types/sd/sdAdGroup.md (3664b), references/report-types/sd/sdAdvertisedProduct.md (3473b), references/report-types/sd/sdCampaigns.md (3878b), references/report-types/sd/sdGrossAndInvalids.md (2544b), references/report-types/sd/sdPurchasedProduct.md (2742b), references/report-types/sd/sdTargeting.md (4672b), references/report-types/sp/index.md (494b), references/report-types/sp/spAdvertisedProduct.md (2794b), references/report-types/sp/spCampaigns.md (6362b), references/report-types/sp/spGrossAndInvalids.md (2747b), references/report-types/sp/spPromptAdExtension.md (3887b), references/report-types/sp/spPurchasedProduct.md (2869b), references/report-types/sp/spSearchTerm.md (4766b), references/report-types/sp/spTargeting.md (5365b), scripts/check_auth_dependency.py (6741b), scripts/get_report.py (32807b), scripts/onboarding.py (24027b), skill-card.md (2669b), SKILL.md (16541b), _meta.json (144b)\n\nFile v1.0.8:SKILL.md\n\n---\nname: linkfox-amazon-ads-report\ndescription: 亚马逊广告（Amazon Ads）报告一站式获取技能，覆盖 Sponsored Products (SP) / Sponsored Brands (SB) / Sponsored Display (SD) 全部报告类型。脚本自动完成报告的创建、等待、下载和解压，直接返回可读的结构化数据。真实可用的报告类型及每类的列清单/groupBy/filters 以 `references/report-types/{adProduct-dir}/{reportTypeId}.md` 为单一真相源。当用户提到拉取亚马逊广告报告、下载 Amazon Ads 报告、获取 SP/SB/SD 广告活动/关键词/搜索词/投放商品/购买商品/广告组/流量异常/Prompt 扩展等任意报告时触发。本技能依赖 linkfox-amazon-ads-auth。Sponsored Television (ST) / Amazon DSP 暂未覆盖。\n---\n\n# Amazon Ads 报告获取\n\n报告一站式获取：脚本经 `developerProxy` 传 `profileId`（服务端解析 token），自动完成报告的创建、等待（约 2–10 分钟）、下载和解压，直接返回可读的结构化数据。\n脚本本身不做\"该选哪些列 / 该怎么分组\"的业务判断，这些由 agent 先查 `references/report-types/` 下对应的 `.md` 文件，再显式传给脚本。\n\n**依赖 `linkfox-amazon-ads-auth`**（脚本启动自动检查；未安装时 exit 42，stderr 打 `DEPENDENCY_MISSING`）。\n\n### ⚠️ 多账号场景：调用前必须解析好 profileId\n\n用户经常只说自然语言（\"美国站\"、\"日本站\"、\"我的店铺\"），本 skill 的所有脚本都必须拿到数字 `profileId` 才能调。按下列顺序处理，**不要跳过**：\n\n1. 先调 `linkfox-amazon-ads-auth` 的 `authorized_stores.py` 拉出用户已授权的账号 × 站点清单。\n2. 根据用户提到的站点（映射到 `countryCode`，如 美国→`US`）匹配候选 profile：\n   - **只有 1 个候选** → 静默取对应 profileId，继续调用；不要把 profileId 数字播报给用户。\n   - **≥ 2 个候选（同站点下多个授权账号）** → **必须向用户澄清**，用 `accountName` 问：\"你在美国站授权了 A 和 B 两个账号，这次用哪个？\"\n   - **0 个候选** → 告知用户该站点未授权，引导去 `linkfox-amazon-ads-auth` 做授权。\n3. **严禁**让用户直接报 profileId 数字。\n4. **严禁**在歧义下\"挑第一个\"或\"选默认\"绕过澄清。\n\n完整决策表见 `linkfox-amazon-ads-auth` SKILL.md 的 **Usage Scenarios 第 4 节**。\n\n## 调用方式\n\n- **API 端点**：`POST /amazonAds/developerProxy`（不同操作通过请求体区分；完整参数/响应/错误码见 `references/api.md`）\n- **Python 脚本**：`python scripts/<脚本名>.py '<JSON 参数>' [--inline]`（可用脚本见上文脚本一览）\n- **成本约束**：本工具会消耗算力；失败/空结果不得自动换关键词、翻页或连续试探；需要继续检索时先向用户说明会产生额外消耗。\n\n**输出策略（脚本默认行为）**：\n- **始终**将完整响应写入 `<cwd>/linkfox/<YYYY-MM-DD>/<session>/data/<skill-name>-<timestamp>.json`（`<cwd>` 为脚本执行时的工作目录，在 Claude Code 里即当前项目目录；`<session>` 取自环境变量 `SESSION_ID`，按用户任务自动聚合；**禁止写入 /tmp**，当前目录不可写则报错）\n- 响应体 ≤ 8 KB：落盘后把完整 JSON 打印到 stdout\n- 响应体 > 8 KB：落盘后 stdout 只输出摘要（顶层字段、常见计数如 `total`/`costToken`、最大列表字段的长度 + 前 3 条样本）\n- 加 `--inline` 强制全量打印到 stdout（同样落盘）\n\n**读数据建议**：先看摘要判断是否足够；需要具体字段时优先用 `jq`或`ConvertFrom-Json`或`ConvertFrom-Json` 从保存的 json 文件按需抽取，避免整份 JSON 进入上下文。\n\n## 解决认证和算力问题\n发生以下异常情况时，采用 references/onboarding.md 引导解决问题：\n\n### 异常情况\n- **未配置API Key**：环境变量未配置 `LINKFOX_AGENT_API_KEY`，也未配置 `LINKFOXAGENT_API_KEY`。\n- **响应401或402状态码**\n- **响应提示算力或余额不足**：消息含\"算力余额不足/计费不足/余额不足/quota exceeded/insufficient balance/套餐到期/需充值/请充值\"，或类似含义的内容。\n\n## Core Concepts\n\n- **覆盖**：SP / SB / SD 全部报告类型（以 `references/report-types/` 下存在的 `.md` 为准；ST / DSP 暂未覆盖）\n- **一站式**：脚本内部自动完成报告创建 → 等待生成（约 2–10 分钟）→ 下载 → 解压，调用方只需等最终结果\n- **单脚本**：`get_report.py`（覆盖 SP / SB 全部 adProduct）\n- **元数据 vs. 运行参数**：\n  - 每个报告类型的**可用字段**（timeUnit / groupBy / filters / 全部列名）集中在 `references/report-types/<adProduct-dir>/<reportTypeId>.md`\n  - **脚本运行参数**（等待间隔、访问链接时效等）见本文件和 `references/api.md`\n\n## 可用脚本\n\n| 脚本 | 职责 |\n|------|------|\n| `get_report.py` ⭐ | 一站式执行。**必填** `adProduct` / `groupBy` / `columns`，由 agent 从 report-types/ 提取后传入 |\n| `check_auth_dependency.py` | 检测 linkfox-amazon-ads-auth 是否安装 |\n\n完整脚本参数、响应结构见 `references/api.md`。\n\n## Agent 调用流程\n\nAgent 触达\"拉取亚马逊广告报告\"类需求时，**必须**按下列顺序：\n\n1. **定 reportTypeId**：按用户意图挑选（如\"上周花费\"→ `spCampaigns`；\"哪个商品卖得好\"→ `spAdvertisedProduct` / `sbPurchasedProduct`；\"用户搜什么词找到我\"→ `spSearchTerm`）\n2. **查 reference**：打开 `references/report-types/<adProduct-dir>/<reportTypeId>.md`\n   - **frontmatter** 给出：`adProduct` / `groupBy`（Configuration 表推荐的） / `timeUnit`(可枚举) / `format` / `dateRange` / `filters`\n   - **Base metrics 表** 给出：此报告类型允许的全部列名\n3. **向用户咨询可定制条件**（用户答\"默认/随便\"时跳过，进入第 4 步的默认选择）：\n   - `timeUnit`：DAILY（按日拆分）还是 SUMMARY（汇总）\n   - `columns` 扩展：是否要归因列（sales7d / purchases7d / acosClicks7d / roasClicks7d）、视频指标、newToBrand 等\n   - `filters`：是否过滤 campaignStatus / keywordType / adStatus 等\n4. **按用户回复或默认构造 columns**（见下节 \"默认条件\"）\n5. **调脚本**：`adProduct` / `groupBy` / `columns` 三个必填字段**显式**传入\n\n## 默认条件（用户未指定时使用）\n\n| 条件 | 默认规则 |\n|------|---------|\n| `timeUnit` | 日期跨度 ≤ 7 天 → `DAILY`；> 7 天 → `SUMMARY` |\n| `columns` 身份维度 | `DAILY` 时必含 `date`；`SUMMARY` 时必含 `startDate` + `endDate`；再追加该报告的主键字段（参考 frontmatter 中 groupBy 对应的主键，如 campaignId+campaignName / advertisedAsin+advertisedSku / searchTerm / keyword 等） |\n| `columns` 基础指标 | `impressions` / `clicks` / `cost`（以该报告 Base metrics 存在的为准） |\n| `columns` 归因指标 | **仅当用户提到\"销售/转化/ROI/ACOS\"等意图时追加**：`sales7d` / `purchases7d` / `acosClicks7d` / `roasClicks7d`（以 Base metrics 存在者为准） |\n| `filters` | 不加（全量返回） |\n| `groupBy` | 取 frontmatter `groupBy` 数组的第一个值（即 Configuration 表里 Amazon 官方推荐的主维度） |\n\n## 请求示例\n\n所有 example 都显式传入三个必填字段（`adProduct` / `groupBy` / `columns`）。\n\n### 1. SP 广告活动报告（最常见）\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"adProduct\": \"SPONSORED_PRODUCTS\",\n  \"groupBy\": [\"campaign\"],\n  \"columns\": [\"date\",\"campaignId\",\"campaignName\",\"impressions\",\"clicks\",\"cost\"],\n  \"startDate\": \"2026-04-27\",\"endDate\": \"2026-05-03\",\n  \"timeUnit\": \"DAILY\"\n}'\n```\n\n### 2. SP 搜索词报告（含归因）\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"spSearchTerm\",\n  \"adProduct\": \"SPONSORED_PRODUCTS\",\n  \"groupBy\": [\"searchTerm\"],\n  \"columns\": [\"searchTerm\",\"keyword\",\"matchType\",\"impressions\",\"clicks\",\"cost\",\n              \"sales7d\",\"sales14d\",\"purchases7d\",\"acosClicks14d\",\"roasClicks14d\",\n              \"startDate\",\"endDate\"],\n  \"startDate\": \"2026-04-01\",\"endDate\": \"2026-04-30\",\n  \"timeUnit\": \"SUMMARY\",\n  \"filters\": [{\"field\":\"keywordType\",\"values\":[\"BROAD\",\"PHRASE\",\"EXACT\"]}]\n}'\n```\n\n### 3. SB 广告组报告\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"sbAdGroup\",\n  \"adProduct\": \"SPONSORED_BRANDS\",\n  \"groupBy\": [\"adGroup\"],\n  \"columns\": [\"adGroupId\",\"adGroupName\",\"impressions\",\"clicks\",\"cost\",\"purchases\",\"sales\",\"startDate\",\"endDate\"],\n  \"startDate\": \"2026-04-01\",\"endDate\": \"2026-04-30\"\n}'\n```\n\n### 4. SD 广告活动报告\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"sdCampaigns\",\n  \"adProduct\": \"SPONSORED_DISPLAY\",\n  \"groupBy\": [\"campaign\"],\n  \"columns\": [\"date\",\"campaignId\",\"campaignName\",\"impressions\",\"clicks\",\"cost\",\"purchases\",\"sales\"],\n  \"startDate\": \"2026-04-27\",\"endDate\": \"2026-05-03\",\n  \"timeUnit\": \"DAILY\"\n}'\n```\n\n### 5. 轮询一个已有 reportId（救回上次超时 / 手工恢复）\n\n当上次运行因为客户端轮询窗口太短退出、但报告在 Amazon 侧仍在跑时，直接传入 `reportId` 即可跳过创建，继续轮询并下载。此模式下只需 `profileId` / `region` / `reportId`，其余字段不必填。\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportId\": \"7df1ef5d-45ba-40cc-b607-ff2148cf4f5e\",\n  \"maxAttempts\": 60, \"pollInterval\": 30\n}'\n```\n\n> **自动恢复**：如果调用方未传 `reportId`、且 Amazon 对同参数请求触发去重（返回 HTTP 425 `The Request is a duplicate of : <uuid>`），脚本会自动解析出老 reportId 并转为轮询该老报告，无需重试。\n\n## 响应格式\n\n成功：\n```json\n{\n  \"success\": true,\n  \"reportId\": \"4ee811a0-...\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"startDate\": \"2026-04-28\", \"endDate\": \"2026-05-04\",\n  \"downloadPath\": \"C:/.../tmp/report_data.json\",\n  \"extractedFileHttpUrl\": \"http://127.0.0.1:51234/download\",\n  \"extractedFileHttpServeSeconds\": 300\n}\n```\n\n失败：\n```json\n{\"error\":\"Upstream HTTP 400\",\"httpStatus\":400,\n \"body\":\"{\\\"code\\\":\\\"400\\\",\\\"detail\\\":\\\"startDate to endDate range (32 days) must not exceed maximum range (31 days)\\\"}\"}\n```\n\n## 调用原则\n\n- 用户指定了 reportTypeId 就只拉那一种，不擅自替换\n- 报告失败（非 2xx 或 status=FAILED）时如实告知错误原因，不盲目重试\n- 成功后把报告的本地文件路径和访问链接完整展示给用户，并提醒访问链接有时效（默认 5 分钟内有效，过期需重新拉取）\n- **超时不是失败**：当脚本返回 `status=STILL_PROCESSING`（exit code=2），说明客户端已等满默认约 7.5 分钟但报告仍在 Amazon 侧生成。此时 **必须**向用户说明情况并询问是否继续等待，绝不能当成失败处理。参考回复：\"报告还在 Amazon 侧生成中（已等约 7.5 分钟），要继续等吗？可以选：A. 再等 ~30 分钟（maxAttempts=60）、B. 再等 ~1 小时（maxAttempts=120）、C. 先停，我稍后用 reportId 回来。\" 用户选 A/B → 用 `resumeHint.params` 切到仅轮询模式续跑\n\n## 常见错误\n\n| 状态 | 含义 | 建议 |\n|------|------|------|\n| `Missing required parameters: adProduct/groupBy/columns` | 调用方未显式传入三必填 | 回到 \"Agent 调用流程\" 第 2 步，从 `references/report-types/<adProduct-dir>/<reportTypeId>.md` 读出并补上 |\n| `HTTP 401` | accessToken 过期 | 调 ads-auth 的 `refresh_token.py` 后重试 |\n| `HTTP 403` | 未关联广告账户或权限不足 | 到 Amazon Ads 后台检查经理账户/广告账户关联 |\n| `HTTP 400 \"must not exceed maximum range\"` | 日期跨度超限（多数 31 天） | 拆分拉取后本地合并；具体上限看对应 `.md` frontmatter `dateRange.maxSpanDays` |\n| `HTTP 400` 含 `columns`/`groupBy` 校验错 | 列名拼写错 / 与 reportTypeId 不匹配 / 超出 Base metrics | 对照 `.md` 文件 Base metrics 表核对 |\n| `status=FAILED` 含 `failureReason` | 上游生成失败 | 多为日期窗口或权限问题，按 failureReason 具体处理 |\n| `status=STILL_PROCESSING` (exit 2) | 客户端轮询窗口耗尽但报告仍在生成 | **不是失败**。stdout 已含 `reportId` 与 `resumeHint.params`。询问用户是否继续等，用该 params（带 `reportId` + 更大 `maxAttempts`）切到仅轮询模式续跑 |\n| `HTTP 425 \"duplicate of\"` | 同参数已有在跑的报告 | 脚本自动解析并转为轮询该老 reportId，正常情况下调用方无需干预 |\n| exit 42 | 依赖 skill 未安装 | 先装 `linkfox-amazon-ads-auth` |\n\n## 日期与数据\n\n- **日期跨度上限**：多数报告 31 天；`sbPurchasedProduct` 是 731 天；`spGrossAndInvalids` / `sbGrossAndInvalids` / `sdGrossAndInvalids` 是 365 天（以 frontmatter 为准）\n- **回溯窗口**：SP 默认 95 天、SB 60 天、GrossAndInvalids 365 天；具体以 frontmatter `dateRange.dataRetentionDays` 为准\n- **数据延迟约 12 小时**；`endDate >= 今天` 脚本 stderr 警告但不拦截\n- **空数据不等于报错**：账号当期无投放时报告会成功生成，JSON 可能为 `[]` 或指标全 0\n\n## Not Applicable\n\n- Brand Analytics / Retail Analytics / Attribution 报告 → 不在本 skill\n- 报告删除 / 修改 / 定时任务 → 不在本 skill\n- 实体元数据（campaign 名、keyword 匹配类型等）→ `linkfox-amazon-ads-manager`\n- 授权 / token → `linkfox-amazon-ads-auth`\n\n## Amazon Ads API 接口保护与重试指引\n\n同一广告账号/profile 连续收到 Amazon Ads API 的 400、403、404 或 429 时，网关会返回 450、453、454 或 459 并短暂冷却。这些自定义状态码不是 Amazon 原生状态，也不表示封号；目的是避免持续异常或高频调用扩大广告账号风险。\n\n| 状态与 message | 范围 | 触发与冷却 | 处理 |\n|---|---|---|---|\n| `450`：`400，请求异常，请优化您的参数` | 广告账号/profile+接口 | 60 秒内超过 3 次：5 分钟；10 分钟内超过 4 次：20 分钟 | 停止原参数重试，检查 profileId、region、实体/报告 ID、日期和请求体 |\n| `453`：`403，店铺未授权，请先授权` | 广告账号/profile 全部接口 | 60 秒内超过 2 次：5 分钟；10 分钟内超过 4 次：30 分钟 | 停止该广告账号调用，检查 Ads 授权、应用权限、profile 归属和区域 |\n| `454`：`404，资源不存在，请优化您的参数` | 广告账号/profile+接口 | 60 秒内超过 3 次：5 分钟；10 分钟内超过 4 次：30 分钟 | 确认资源 ID、所属 profile/区域、资源状态和接口路径 |\n| `459`：`429限流中，请降低频率` | 广告账号/profile+接口 | 首次：15 秒；2 分钟内超过 2 次：30 秒；3 分钟内超过 4 次：2 分钟 | 降低并发、分页和轮询频率并逐级退避 |\n\n- 立即停止自动或并发重试，不得通过换脚本或重复创建任务绕过保护；优先遵循 `retryAfter`、`blockedUntil`，没有时按表中时长说明。\n- 450/453/454 必须先修正参数、授权或资源标识，冷却后最多谨慎重试一次；再次触发则停止调用。453 期间停止该广告账号/profile 全部 Ads API。\n- 保留已有 `reportId` 等任务 ID；写操作结果不确定时先查询状态，不直接重放。\n- 向用户先说明广告账号保护，再给原因、处理和等待时间。可回复：“为保护您的亚马逊广告账号安全，检测到 Amazon Ads API 连续返回{原因}，当前已进入短暂保护。请先{处理动作}，预计{等待时间}后再试；这不代表封号，也不是套餐或积分限制。”不要只说“LinkFox 限流”或“服务器繁忙”。\n\n## 算力消耗规则\n\n不消耗算力。\n\n**Feedback:**\n\nAuto-detect and report feedback via the Feedback API when any of the following apply:\n1. The functionality or purpose described in this skill does not match actual behavior\n2. The skill's results do not match the user's intent\n3. The user expresses dissatisfaction or praise about this skill\n4. Anything you believe could be improved\n\nCall the feedback API as specified in `references/api.md`. Do not interrupt the user's flow.\n\n---\n*For more high-quality, professional cross-border e-commerce skills, visit [LinkFox Skills](https://skill.linkfox.com/).*\n\nFile v1.0.8:_meta.json\n\n{\n  \"ownerId\": \"kn7dmc1t4j28hem1twwyav85p182pb1j\",\n  \"slug\": \"linkfox-amazon-ads-report\",\n  \"version\": \"1.0.8\",\n  \"publishedAt\": 1789361654458\n}\n\nFile v1.0.8:references/api.md\n\n# linkfox-amazon-ads-report — 参数与字段参考\n\nAmazon Ads 报告自动化获取（SP / SB 覆盖；SD / ST / DSP 暂未覆盖）。授权见 `linkfox-amazon-ads-auth`；广告管理见 `linkfox-amazon-ads-manager`。\n\n> **📌 报告类型的真相源**：每个 `reportTypeId` 的完整规格（可用 columns / groupBy / filters / timeUnit / 日期约束 / 官方示例）在 `references/report-types/<adProduct-dir>/<reportTypeId>.md`，**按 adProduct 分目录**：\n> - `report-types/sp/`（Sponsored Products）\n> - `report-types/sb/`（Sponsored Brands）\n>\n> 目录总览见 `report-types/index.md`。本文件仅给运行时脚本参数与通用规则。\n\n## 支持的报告类型\n\n完整列表见 `report-types/index.md` 及各 adProduct 子目录下的 `index.md`。常用快速索引：\n\n| reportTypeId | 业务含义 | 文件 |\n|--------------|---------|------|\n| `spCampaigns` | 广告活动级（SP） | `report-types/sp/spCampaigns.md` |\n| `spAdvertisedProduct` | 投放商品级（SP） | `report-types/sp/spAdvertisedProduct.md` |\n| `spSearchTerm` | 搜索词级（SP） | `report-types/sp/spSearchTerm.md` |\n| `spTargeting` | 定向/关键词级（SP） | `report-types/sp/spTargeting.md` |\n| `sbCampaigns` / `sbAdGroup` / `sbAds` / ... | Sponsored Brands | `report-types/sb/*.md` |\n\n## 输入参数\n\n脚本支持两种模式：\n\n- **全链路模式（默认）**：创建报告 → 轮询 → 下载。需要下表全部必填字段。\n- **仅轮询模式**：入参中显式传入 `reportId`（见下方\"可选流程参数\"），跳过创建，只需 `profileId` / `region`，其余全部可省略。用于救回上次客户端超时但报告仍在跑的场景。\n\n### 必填（全链路模式）\n\n| 参数 | 类型 | 说明 |\n|------|------|------|\n| `profileId` | number | 从 ads-auth 获取 |\n| `region` | string | `NA` / `EU` / `FE` |\n| `reportTypeId` | string | 见 `report-types/index.md` 各 adProduct 子目录下的完整列表 |\n| `adProduct` | string | 取自对应 `.md` 文件的 frontmatter（`SPONSORED_PRODUCTS` / `SPONSORED_BRANDS`）|\n| `groupBy` | list | 取自对应 `.md` 文件的 frontmatter |\n| `columns` | list | 取自对应 `.md` 文件 Base metrics 表的子集 |\n| `startDate` | string | `YYYY-MM-DD`（含当天） |\n| `endDate` | string | `YYYY-MM-DD`（含当天） |\n\n### 可选业务参数\n\n| 参数 | 默认 | 说明 |\n|------|------|------|\n| `name` | `{reportTypeId}_{startDate}_{endDate}` | 报告显示名 |\n| `timeUnit` | `SUMMARY` | `DAILY`（每天一行） / `SUMMARY`（整期一行） |\n| `format` | `GZIP_JSON` | 响应文件格式 |\n| `filters` | 空 | 过滤条件数组，字段与取值见对应 `.md` 文件 |\n\n### 可选流程参数\n\n| 参数 | 默认 | 说明 |\n|------|------|------|\n| `reportId` | 无 | 若显式传入，脚本进入**仅轮询模式**：跳过创建步骤，直接对该 reportId 轮询与下载。此时只要 `profileId` / `region` + `reportId`，其他字段可省 |\n| `pollInterval` | 30 | 轮询间隔秒 |\n| `maxAttempts` | 15 | 最大轮询次数（默认约 7.5 分钟上限） |\n| `skipDepCheck` | false | 跳过依赖检查 |\n| `serveExtractedFileHttp` | true | 是否启本机 HTTP 服务 |\n| `serveHost` | `127.0.0.1` | 绑定地址（仅本机可访问） |\n| `servePort` | 0 | 端口（0=系统分配） |\n| `serveSeconds` | 300 | HTTP 服务存活秒 |\n| `includeAmazonSourceUrl` | false | 响应中带预签名 URL |\n\n## 日期限制\n\n- **跨度上限**：以对应 `.md` 文件 frontmatter 的 `dateRange.maxSpanDays` 为准（多数 31 天；`sbPurchasedProduct` 731 天；GrossAndInvalids 系列 365 天）。超出返回 HTTP 400 `\"must not exceed maximum range\"`。\n- **回溯上限**：以 `dateRange.dataRetentionDays` 为准（SP 多为 95 天，SB 60 天）。\n- **数据延迟**：~12 小时；`endDate >= 今天` 脚本会 stderr 警告但不拦截。建议 `endDate <= 昨天`。\n\n## 各报告类型的列\n\n每个 reportTypeId 的完整 Base metrics 列表、allowed groupBy、filters 枚举值，统一在 `report-types/<adProduct-dir>/<reportTypeId>.md` 中维护：\n\n- `.md` 的 **frontmatter** 提供 `adProduct` / `groupBy` / `timeUnit`（可选值）/ `format` / `filters` / `dateRange`\n- **Base metrics 表**列出此报告类型支持的**全部列名**；调用方按业务需要选子集\n\n归因窗口后缀约定：`_1d` / `_7d` / `_14d` / `_30d` 表示 1/7/14/30 天归因窗口（点击或曝光归因的销售额、订单量、件数等）。具体每个字段支持哪些窗口，以对应 `.md` 文件的 Base metrics 表为准（不是所有字段都有全部 4 个窗口版本）。\n\n## 工作流与输出\n\n脚本流程：依赖检查 → 取 token → 创建报告 → 等待生成（每 `pollInterval` 秒查询一次状态）→ 下载 GZIP_JSON（Amazon 预签名 URL 约 1 小时有效）→ 解压为可读 JSON → 通过本机 `127.0.0.1` 上的临时 HTTP 服务对调用方暴露（`serveSeconds` 后自动关闭）→ 输出调用结果 JSON（含本地文件路径与访问链接）。\n\n`status` 枚举：`PENDING` / `PROCESSING` / `COMPLETED` / `FAILED`。\n\n### 成功响应\n\n```json\n{\n  \"success\": true,\n  \"reportId\": \"4ee811a0-6aaa-4ceb-9d31-d3bcecf85430\",\n  \"status\": \"COMPLETED\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"startDate\": \"2026-04-28\", \"endDate\": \"2026-05-04\",\n  \"pollAttempts\": 13, \"elapsedSeconds\": 255,\n  \"downloadPath\": \"C:/.../tmp/report-xxx.json\",\n  \"extractedFileHttpUrl\": \"http://127.0.0.1:51234/report-xxx.json\",\n  \"serveExpiresAt\": \"2026-05-06T14:54:03+08:00\"\n}\n```\n\n### 失败响应\n\n**a) 创建阶段非 2xx**：\n```json\n{\"error\":\"Upstream HTTP 400\",\"httpStatus\":400,\n \"body\":\"{\\\"code\\\":\\\"400\\\",\\\"detail\\\":\\\"startDate to endDate range (32 days) must not exceed maximum range (31 days)\\\"}\"}\n```\n\n**b) 报告生成失败**（`failureReason` 从上游透传）：\n```json\n{\"success\":false,\"error\":\"Report generation failed with status=FAILED\",\n \"reportId\":\"4ee811a0-...\",\"status\":\"FAILED\",\n \"failureReason\":\"Requested columns are not supported for this report type.\",\n \"pollAttempts\":3}\n```\n\n**c) 轮询超时**（报告未坏，仅客户端等待窗口耗尽 — **exit code = 2**）：\n```json\n{\n  \"success\": false,\n  \"status\": \"STILL_PROCESSING\",\n  \"reportId\": \"4ee811a0-...\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"profileId\": 1234567890,\n  \"lastStatus\": \"PROCESSING\",\n  \"pollAttempts\": 15,\n  \"elapsedSeconds\": 450,\n  \"message\": \"客户端已等 ~450 秒（15 次轮询）报告仍在 Amazon 侧生成，并未失败。用 reportId 切换到仅轮询模式即可继续等待。\",\n  \"resumeHint\": {\n    \"mode\": \"poll-only\",\n    \"note\": \"传入 reportId + 更大的 maxAttempts 继续轮询同一份报告\",\n    \"params\": {\"profileId\": 1234567890, \"region\": \"NA\", \"reportId\": \"4ee811a0-...\", \"maxAttempts\": 60, \"pollInterval\": 30}\n  }\n}\n```\n\n调用方收到此响应应视为\"未完成\"而非\"失败\"，询问用户是否继续等待，直接把 `resumeHint.params` 作为入参续调 `get_report.py`。\n\n## 错误码\n\n| httpStatus / exit | 含义 | 建议 |\n|-------------------|------|------|\n| 200 | 成功 | 消费 `extractedFileHttpUrl` 或 `downloadPath` |\n| 400 | 入参错（日期超限 / reportTypeId 非法 / columns 不适配） | 按 `detail` 修正 |\n| 401 | accessToken 过期 | HTTP 401 或 authorized error：按 SKILL.md 的 **## 解决认证和算力问题** 处理。 |\n| 402 | 算力或余额不足 | HTTP 402：按 SKILL.md 的 **## 解决认证和算力问题** 处理。 |\n| 403 | profileId 无权限 | 核对 profileId |\n| 404 | reportId 不存在或已过期 | 重新发起报告 |\n| 422 | columns / groupBy 与 reportTypeId 不适配 | 对照 `report-types/<adProduct-dir>/<reportTypeId>.md` 的 Base metrics / frontmatter 核对 |\n| 425 | 同参数已有在跑的报告，Amazon 做了去重；body 形如 `\"The Request is a duplicate of : <reportId>\"` | **脚本自动解析该 reportId 并无缝转为轮询该老报告**，正常情况下无需干预；若调用方自行处理，也可把 reportId 拿出来，下次改用仅轮询模式（`{..., \"reportId\":\"<uuid>\"}`） |\n| 429 | 限流（~30 req/min/profile） | 间隔 30s 重试 |\n| `status=FAILED` | 上游生成失败 | 看 `failureReason` |\n| `status=STILL_PROCESSING` (exit 2) | 客户端轮询窗口耗尽但报告仍在 Amazon 侧生成 | **非失败**。stdout 已输出 `reportId` 与 `resumeHint.params`。询问用户是否继续等，用 params 切到仅轮询模式续跑（maxAttempts=60 约 30 分钟 / =120 约 1 小时） |\n| exit 42 | 依赖 skill 未安装 | 先装 `linkfox-amazon-ads-auth` |\n\n## 调用示例\n\n```bash\n# 1. SP 广告活动汇总（DAILY，一周）\npython get_report.py '{\"profileId\":1111111111,\"region\":\"NA\",\n  \"reportTypeId\":\"spCampaigns\",\n  \"adProduct\":\"SPONSORED_PRODUCTS\",\n  \"groupBy\":[\"campaign\"],\n  \"columns\":[\"date\",\"campaignId\",\"campaignName\",\"impressions\",\"clicks\",\"cost\"],\n  \"startDate\":\"2026-04-27\",\"endDate\":\"2026-05-03\",\n  \"timeUnit\":\"DAILY\"}'\n\n# 2. SP 搜索词 + 多归因窗口 + 过滤仅看关键词匹配\npython get_report.py '{\"profileId\":1111111111,\"region\":\"NA\",\n  \"reportTypeId\":\"spSearchTerm\",\n  \"adProduct\":\"SPONSORED_PRODUCTS\",\n  \"groupBy\":[\"searchTerm\"],\n  \"columns\":[\"searchTerm\",\"keyword\",\"matchType\",\"impressions\",\"clicks\",\"cost\",\n             \"sales7d\",\"sales14d\",\"sales30d\",\n             \"purchases7d\",\"purchases14d\",\"purchases30d\",\n             \"acosClicks14d\",\"roasClicks14d\",\"startDate\",\"endDate\"],\n  \"startDate\":\"2026-04-01\",\"endDate\":\"2026-04-30\",\n  \"timeUnit\":\"SUMMARY\",\n  \"filters\":[{\"field\":\"keywordType\",\"values\":[\"BROAD\",\"PHRASE\",\"EXACT\"]}]}'\n\n# 3. SP 投放商品 + 长时间等待 + 不启本机 HTTP\npython get_report.py '{\"profileId\":1111111111,\"region\":\"NA\",\n  \"reportTypeId\":\"spAdvertisedProduct\",\n  \"adProduct\":\"SPONSORED_PRODUCTS\",\n  \"groupBy\":[\"advertiser\"],\n  \"columns\":[\"advertisedAsin\",\"advertisedSku\",\"impressions\",\"clicks\",\"cost\",\n             \"sales7d\",\"acosClicks7d\",\"roasClicks7d\",\"startDate\",\"endDate\"],\n  \"startDate\":\"2026-04-01\",\"endDate\":\"2026-04-30\",\n  \"timeUnit\":\"SUMMARY\",\n  \"maxAttempts\":60,\"pollInterval\":20,\"serveExtractedFileHttp\":false}'\n\n# 4. 仅轮询一个已有 reportId（救回上次超时）\npython get_report.py '{\"profileId\":1111111111,\"region\":\"NA\",\n  \"reportId\":\"7df1ef5d-45ba-40cc-b607-ff2148cf4f5e\",\n  \"maxAttempts\":60,\"pollInterval\":30}'\n```\n\n---\n\n## Feedback API\n\n与上面的工具 API **base URL 不同**：\n\n```bash\ncurl -X POST https://skill-api.linkfox.com/api/v1/public/feedback \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"skillName\":\"linkfox-amazon-ads-report\",\"sentiment\":\"POSITIVE\",\n       \"category\":\"OTHER\",\"content\":\"报告拉取顺利\"}'\n```\n\n- `sentiment`: `POSITIVE` / `NEUTRAL` / `NEGATIVE`\n- `category`: `BUG` / `COMPLAINT` / `SUGGESTION` / `OTHER`\n\nFile v1.0.8:references/onboarding.md\n\n# 解决认证和算力问题\n\n调用本 skill 时若网关返回 **auth** 或 **billing** 错误，走本 skill 自带的 `scripts/onboarding.py` 完成引导。\n\n**auth 场景**：`errcode=401` 或消息含 `authorized error`/`鉴权失败`/`未授权`/`unauthorized`；或 `LINKFOX_AGENT_API_KEY` 与 `LINKFOXAGENT_API_KEY` 均为空。\n1. 若已配置 key → 先让用户重启会话（最常见误判），仍失败让用户重新取 key 或换手机号重注册\n2. 未配置 → 询问：自助去 https://agent.linkfox.com/ 取 key，或提供手机号让脚本注册\n3. 手机号路径：\n   - `python scripts/onboarding.py send-code <phone>` → 展示 JSON 里的 phone/agreements\n   - 收到验证码后：`python scripts/onboarding.py login <phone> <code>`\n   - 拿到 `api_key` 后把下面三平台配置转发给用户，提示重启会话生效：\n     - Windows PowerShell（永久）：`setx LINKFOX_AGENT_API_KEY \"<key>\"`\n     - macOS zsh：`echo 'export LINKFOX_AGENT_API_KEY=\"<key>\"' >> ~/.zshrc && source ~/.zshrc`\n     - Linux bash：`echo 'export LINKFOX_AGENT_API_KEY=\"<key>\"' >> ~/.bashrc && source ~/.bashrc`\n     - 变量名 `LINKFOX_AGENT_API_KEY`（主推）或 `LINKFOXAGENT_API_KEY`（老规范）任一即可\n\n**billing 场景**：`errcode=402` 或消息含 `算力/余额/quota/insufficient/充值/套餐到期`。\n- `python scripts/onboarding.py list-plans` → 有 AskUserQuestion 就弹菜单，否则输出编号清单让用户选\n- 校验 `plan_id` ∈ 清单、支付方式 ∈ 该套餐 `available_methods`（通常 `wechat/alipay`）\n- `python scripts/onboarding.py order <plan_id> <method>` → 展示优先级 PNG > `pay_url` > `ascii_qr`（标注兜底）\n- 已付款可选调 `python scripts/onboarding.py query <order_id>`，不主动轮询\n\n排除 `errcode=403`（无权限，不归入这两类）。所有子命令输出 stdout JSON，`error` 字段已含阶段前缀，透传给用户即可。完整用法：`python scripts/onboarding.py --help`。\n\nFile v1.0.8:references/report-types/index.md\n\n# Amazon Ads Report Types\n\n按 `adProduct` 分类。每个 `.md` 文件名即 `reportTypeId`，内容为官方原文 + YAML frontmatter 结构化字段，用于构造 `POST /reporting/reports` 请求体。\n\n## 目录\n\n| adProduct | 目录 |\n|-----------|------|\n| SPONSORED_PRODUCTS | [`sp/`](./sp/) |\n| SPONSORED_BRANDS | [`sb/`](./sb/) |\n| SPONSORED_DISPLAY | [`sd/`](./sd/) |\n\n> Sponsored Television (ST) / Amazon DSP 暂未覆盖，后续版本支持。\n\n## 数据源\n\nhttps://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types\n\nFile v1.0.8:references/report-types/sb/index.md\n\n# Sponsored Brands (SB) Report Types\n\n`adProduct = SPONSORED_BRANDS`\n\n| reportTypeId | 状态 |\n|--------------|------|\n| [`sbAdGroup`](./sbAdGroup.md) | ✅ |\n| [`sbAds`](./sbAds.md) | ✅ |\n| [`sbCampaigns`](./sbCampaigns.md) | ✅ |\n| [`sbCampaignPlacement`](./sbCampaignPlacement.md) | ✅ |\n| [`sbGrossAndInvalids`](./sbGrossAndInvalids.md) | ✅ |\n| [`sbPromptAdExtension`](./sbPromptAdExtension.md) | ✅ |\n| [`sbPurchasedProduct`](./sbPurchasedProduct.md) | ✅ |\n| [`sbSearchTerm`](./sbSearchTerm.md) | ✅ |\n| [`sbTargeting`](./sbTargeting.md) | ✅ |\n\nFile v1.0.8:references/report-types/sb/sbAdGroup.md\n\n---\nreportTypeId: sbAdGroup\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/ad-group\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [adGroup]\nformat: [GZIP_JSON]\nfilters:\n  - name: adStatus\n    values: [ENABLED, PAUSED, ARCHIVED]\n    applicableWhenGroupBy: [adGroup]\ndateRange:\n  maxSpanDays: 31\n  dataRetentionDays: 60\n---\n\n# SB Ad Group\n\nAd group reports contain performance data broken down at the ad group level. Ad group reports include all campaigns of the requested sponsored ad type that have performance activity for the requested days. For example, a Sponsored Brands ad group report returns performance data for all Sponsored Brands ad groups that received impressions on the chosen dates.\n\n> **Note**\n> For Sponsored Products, there is not a separate ad group report. You can get ad group-level data using the ad group groupBy in a campaign report.\n\n> **Note**\n> This report currently available in preview. During the preview period, data related to Sponsored Brands campaigns with flag isMultiAdGroupsEnabled=False won't be available. Once version 3 reporting supports all Sponsored Brands campaigns, we will announce general availability in the release notes.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbAdGroup |\n| Maximum date range | 31 days |\n| Data retention | 60 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | adGroup |\n| format | GZIP_JSON |\n\n## Base metrics\n\n| Field |\n|------|\n| addToCart |\n| addToCartClicks |\n| addToCartRate |\n| adGroupId |\n| adGroupName |\n| adStatus |\n| addToList |\n| addToListFromClicks |\n| qualifiedBorrows |\n| qualifiedBorrowsFromClicks |\n| royaltyQualifiedBorrows |\n| royaltyQualifiedBorrowsFromClicks |\n| brandedSearches |\n| brandedSearchesClicks |\n| campaignBudgetAmount |\n| campaignBudgetCurrencyCode |\n| campaignBudgetType |\n| campaignId |\n| campaignName |\n| campaignStatus |\n| clicks |\n| cost |\n| costType |\n| date |\n| detailPageViews |\n| detailPageViewsClicks |\n| eCPAddToCart |\n| endDate |\n| impressions |\n| kindleEditionNormalizedPagesRead14d |\n| kindleEditionNormalizedPagesRoyalties14d |\n| newToBrandDetailPageViewRate |\n| newToBrandDetailPageViews |\n| newToBrandDetailPageViewsClicks |\n| newToBrandECPDetailPageView |\n| newToBrandPurchases |\n| newToBrandPurchasesClicks |\n| newToBrandPurchasesPercentage |\n| newToBrandPurchasesRate |\n| newToBrandSales |\n| newToBrandSalesClicks |\n| newToBrandSalesPercentage |\n| newToBrandUnitsSold |\n| newToBrandUnitsSoldClicks |\n| newToBrandUnitsSoldPercentage |\n| purchases |\n| purchasesClicks |\n| purchasesPromoted |\n| sales |\n| salesClicks |\n| salesPromoted |\n| startDate |\n| unitsSold |\n| unitsSoldClicks |\n| video5SecondViewRate |\n| video5SecondViews |\n| videoCompleteViews |\n| videoFirstQuartileViews |\n| videoMidpointViews |\n| videoThirdQuartileViews |\n| videoUnmutes |\n| viewabilityRate |\n\n## Group by adGroup\n\n**Additional metrics**: N/A\n\n**Filters**:\n- adStatus (values: ENABLED, PAUSED, ARCHIVED)\n\n## Group by campaign\n\n**Additional metrics**: N/A\n\n## Sample call\n\n### Ad group summary report grouped by ad group\n\n```bash\ncurl --location 'https://advertising-api.amazon.com/reporting/reports' \\\n--header 'Content-Type: application/vnd.createasyncreportrequest.v3+json' \\\n--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxx' \\\n--header 'Amazon-Advertising-API-Scope: xxxxxxxx' \\\n--header 'Authorization: Bearer Atza|xxxxxxxxxxx' \\\n--data '{\n    \"name\": \"SB ad group report 9/5-9/10\",\n    \"startDate\": \"2023-09-05\",\n    \"endDate\": \"2023-09-10\",\n    \"configuration\": {\n        \"adProduct\": \"SPONSORED_BRANDS\",\n        \"groupBy\": [\n            \"adGroup\"\n        ],\n        \"columns\": [\n            \"impressions\",\n            \"clicks\",\n            \"cost\",\n            \"campaignId\",\n            \"adGroupId\",\n            \"startDate\",\n            \"endDate\"\n        ],\n        \"reportTypeId\": \"sbAdGroup\",\n        \"timeUnit\": \"SUMMARY\",\n        \"format\": \"GZIP_JSON\"\n    }\n}'\n```\n\nFile v1.0.8:references/report-types/sb/sbAds.md\n\n---\nreportTypeId: sbAds\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/ad\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [ads]\nformat: [GZIP_JSON]\nfilters:\n  - name: adStatus\n    values: [ENABLED, PAUSED, ARCHIVED]\n    applicableWhenGroupBy: [ads]\ndateRange:\n  maxSpanDays: 31\n  dataRetentionDays: 60\n---\n\n# SB Ads\n\nAdvertised product reports contain performance data for campaigns at the ad level.\n\n> **Note**\n> This report is currently available in preview. During the preview period, data related to Sponsored Brands campaigns with flag isMultiAdGroupsEnabled set to FALSE won't be available. Once version 3 reporting supports all Sponsored Brands campaigns, we will announce general availability in the release notes.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbAds |\n| Maximum date range | 31 days |\n| Data retention | 60 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | ads |\n| format | GZIP_JSON |\n\n## Base metrics\n\n| Field |\n|------|\n| addToCart |\n| addToCartClicks |\n| addToCartRate |\n| addToList |\n| qualifiedBorrows |\n| royaltyQualifiedBorrows |\n| addToListFromClicks |\n| qualifiedBorrowsFromClicks |\n| royaltyQualifiedBorrowsFromClicks |\n| adGroupId |\n| adGroupName |\n| adId |\n| brandedSearches |\n| brandedSearchesClicks |\n| campaignBudgetAmount |\n| campaignBudgetCurrencyCode |\n| campaignBudgetType |\n| campaignId |\n| campaignName |\n| campaignStatus |\n| clicks |\n| cost |\n| costType |\n| date |\n| detailPageViews |\n| detailPageViewsClicks |\n| eCPAddToCart |\n| endDate |\n| impressions |\n| kindleEditionNormalizedPagesRead14d |\n| kindleEditionNormalizedPagesRoyalties14d |\n| newToBrandDetailPageViewRate |\n| newToBrandDetailPageViews |\n| newToBrandDetailPageViewsClicks |\n| newToBrandECPDetailPageView |\n| newToBrandPurchases |\n| newToBrandPurchasesClicks |\n| newToBrandPurchasesPercentage |\n| newToBrandPurchasesRate |\n| newToBrandSales |\n| newToBrandSalesClicks |\n| newToBrandSalesPercentage |\n| newToBrandUnitsSold |\n| newToBrandUnitsSoldClicks |\n| newToBrandUnitsSoldPercentage |\n| purchases |\n| purchasesClicks |\n| purchasesPromoted |\n| sales |\n| salesClicks |\n| salesPromoted |\n| startDate |\n| unitsSold |\n| unitsSoldClicks |\n| video5SecondViewRate |\n| video5SecondViews |\n| videoCompleteViews |\n| videoFirstQuartileViews |\n| videoMidpointViews |\n| videoThirdQuartileViews |\n| videoUnmutes |\n| viewabilityRate |\n| viewableImpressions |\n\n## Group by ads\n\n**Additional metrics**: N/A\n\n**Filters**:\n- adStatus (values: ENABLED, PAUSED, ARCHIVED)\n\n## Sample call\n\n```bash\ncurl --location 'https://advertising-api.amazon.com/reporting/reports' \\\n--header 'Content-Type: application/vnd.createasyncreportrequest.v3+json' \\\n--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxxxx' \\\n--header 'Amazon-Advertising-API-Scope: xxxxxxx' \\\n--header 'Authorization: Bearer Atza|xxxxxxxxxxx' \\\n--data '{\n    \"name\":\"SB advertised product report 9/5-9/10\",\n    \"startDate\":\"2023-09-05\",\n    \"endDate\":\"2023-09-10\",\n    \"configuration\":{\n        \"adProduct\":\"SPONSORED_BRANDS\",\n        \"groupBy\":[\"ads\"],\n        \"columns\":[\"impressions\",\"clicks\",\"cost\",\"campaignId\",\"adId\",\"adGroupId\"],\n        \"reportTypeId\":\"sbAds\",\n        \"timeUnit\":\"SUMMARY\",\n        \"format\":\"GZIP_JSON\"\n    }\n}'\n```\n\nFile v1.0.8:references/report-types/sb/sbCampaignPlacement.md\n\n---\nreportTypeId: sbCampaignPlacement\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/placement\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [campaign]\nformat: [GZIP_JSON]\nfilters: []\ndateRange:\n  maxSpanDays: 31\n  dataRetentionDays: 60\n---\n\n# SB Campaign Placement\n\nPlacement reports contain performance data broken down by ad placement.\n\n> **Note**\n> For Sponsored Products, there is not a separate placement report. You can get placement-level data using the 'campaignPlacement' groupBy in a campaign report.\n\n> **Note**\n> This report is currently available in preview. During the preview period, data related to Sponsored Brands campaigns with flag isMultiAdGroupsEnabled set to FALSE won't be available. Once version 3 reporting supports all Sponsored Brands campaigns, we will announce general availability in the release notes.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbCampaignPlacement |\n| Maximum date range | 31 days |\n| Data retention | 60 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | campaign |\n| format | GZIP_JSON |\n\n## Base metrics\n\n| Field |\n|------|\n| addToCart |\n| addToCartClicks |\n| addToCartRate |\n| addToList |\n| addToListFromClicks |\n| qualifiedBorrows |\n| qualifiedBorrowsFromClicks |\n| royaltyQualifiedBorrows |\n| royaltyQualifiedBorrowsFromClicks |\n| brandedSearches |\n| brandedSearchesClicks |\n| campaignBudgetAmount |\n| campaignBudgetCurrencyCode |\n| campaignBudgetType |\n| campaignId |\n| campaignName |\n| campaignStatus |\n| clicks |\n| cost |\n| costType |\n| date |\n| detailPageViews |\n| detailPageViewsClicks |\n| eCPAddToCart |\n| endDate |\n| impressions |\n| kindleEditionNormalizedPagesRead14d |\n| kindleEditionNormalizedPagesRoyalties14d |\n| newToBrandDetailPageViewRate |\n| newToBrandDetailPageViews |\n| newToBrandDetailPageViewsClicks |\n| newToBrandECPDetailPageView |\n| newToBrandPurchases |\n| newToBrandPurchasesClicks |\n| newToBrandPurchasesPercentage |\n| newToBrandPurchasesRate |\n| newToBrandSales |\n| newToBrandSalesClicks |\n| newToBrandSalesPercentage |\n| newToBrandUnitsSold |\n| newToBrandUnitsSoldClicks |\n| newToBrandUnitsSoldPercentage |\n| purchases |\n| purchasesClicks |\n| purchasesPromoted |\n| sales |\n| salesClicks |\n| salesPromoted |\n| startDate |\n| unitsSold |\n| unitsSoldClicks |\n| video5SecondViewRate |\n| video5SecondViews |\n| videoCompleteViews |\n| videoFirstQuartileViews |\n| videoMidpointViews |\n| videoThirdQuartileViews |\n| videoUnmutes |\n| viewabilityRate |\n| viewableImpressions |\n| viewClickThroughRate |\n\n## Group by campaignPlacement\n\n**Additional metrics**: placementClassification\n\n## Group by campaign\n\n**Additional metrics**: N/A\n\n## Sample call\n\n### Campaign placement summary report\n\n```bash\ncurl --location 'https://advertising-api.amazon.com/reporting/reports' \\\n--header 'Content-Type: application/vnd.createasyncreportrequest.v3+json' \\\n--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxxxx' \\\n--header 'Amazon-Advertising-API-Scope: xxxxxxx' \\\n--header 'Authorization: Bearer Atza|xxxxxxxx' \\\n--data '{\n    \"name\": \"SB placement report 9/5-9/10\",\n    \"startDate\": \"2023-09-05\",\n    \"endDate\": \"2023-09-10\",\n    \"configuration\": {\n        \"adProduct\": \"SPONSORED_BRANDS\",\n        \"groupBy\": [\n            \"campaignPlacement\"\n        ],\n        \"columns\": [\n            \"impressions\",\n            \"clicks\",\n            \"cost\",\n            \"campaignId\",\n            \"placementClassification\",\n            \"startDate\",\n            \"endDate\"\n        ],\n        \"reportTypeId\": \"sbCampaignPlacement\",\n        \"timeUnit\": \"SUMMARY\",\n        \"format\": \"GZIP_JSON\"\n    }\n}'\n```\n\nFile v1.0.8:references/report-types/sb/sbCampaigns.md\n\n---\nreportTypeId: sbCampaigns\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/campaign\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [campaign]\nformat: [GZIP_JSON]\nfilters:\n  - name: campaignStatus\n    values: [ENABLED, PAUSED, ARCHIVED]\n    applicableWhenGroupBy: [campaign]\ndateRange:\n  maxSpanDays: 31\n  dataRetentionDays: 60\n---\n\n# SB Campaigns\n\nCampaign reports contain performance data broken down at the campaign level. Campaign reports include all campaigns of the requested sponsored ad type that have performance activity for the requested days. For example, a Sponsored Products campaign report returns performance data for all Sponsored Products campaigns that received impressions on the chosen dates. Campaign reports can also be grouped by ad group and placement for more granular data.\n\n> **Note**\n> You can only use a filter that is supported by all groupBy values included in a report configuration. For campaign reports, this means that filters are only supported when you include a single groupBy value.\n\n> **Note**\n> This report currently available in preview. During the preview period, data related to Sponsored Brands campaigns with flag isMultiAdGroupsEnabled=False won't be available. Once version 3 reporting supports all Sponsored Brands campaigns, we will announce general availability in the release notes.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbCampaigns |\n| Maximum date range | 31 days |\n| Data retention | 60 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | campaign |\n| format | GZIP_JSON |\n\n## Base metrics\n\n| Field |\n|------|\n| addToCart |\n| addToCartClicks |\n| addToCartRate |\n| addToList |\n| addToListFromClicks |\n| qualifiedBorrows |\n| qualifiedBorrowsFromClicks |\n| royaltyQualifiedBorrows |\n| royaltyQualifiedBorrowsFromClicks |\n| brandedSearches |\n| brandedSearchesClicks |\n| campaignBudgetAmount |\n| campaignBudgetCurrencyCode |\n| campaignBudgetType |\n| campaignId |\n| campaignName |\n| campaignStatus |\n| clicks |\n| cost |\n| costType |\n| date |\n| detailPageViews |\n| detailPageViewsClicks |\n| eCPAddToCart |\n| endDate |\n| impressions |\n| kindleEditionNormalizedPagesRead14d |\n| kindleEditionNormalizedPagesRoyalties14d |\n| newToBrandDetailPageViewRate |\n| newToBrandDetailPageViews |\n| newToBrandDetailPageViewsClicks |\n| newToBrandECPDetailPageView |\n| brandStorePageView |\n| newToBrandPurchases |\n| newToBrandPurchasesClicks |\n| newToBrandPurchasesPercentage |\n| newToBrandPurchasesRate |\n| newToBrandSales |\n| newToBrandSalesClicks |\n| newToBrandSalesPercentage |\n| newToBrandUnitsSold |\n| newToBrandUnitsSoldClicks |\n| newToBrandUnitsSoldPercentage |\n| purchases |\n| purchasesClicks |\n| purchasesPromoted |\n| sales |\n| salesClicks |\n| salesPromoted |\n| startDate |\n| topOfSearchImpressionShare |\n| unitsSold |\n| unitsSoldClicks |\n| video5SecondViewRate |\n| video5SecondViews |\n| videoCompleteViews |\n| videoFirstQuartileViews |\n| videoMidpointViews |\n| videoThirdQuartileViews |\n| videoUnmutes |\n| viewabilityRate |\n| viewableImpressions |\n| viewClickThroughRate |\n\n## Group by campaign\n\n**Additional metrics**: campaignBudgetAmount, campaignBudgetCurrencyCode, campaignBudgetType, longTermSales, longTermROAS, topOfSearchImpressionShare\n\n**Filters**:\n- campaignStatus (values: ENABLED, PAUSED, ARCHIVED)\n\n## Sample calls\n\n### Campaign summary report grouped by campaign\n\n```bash\ncurl --location 'https://advertising-api.amazon.com/reporting/reports' \\\n--header 'Content-Type: application/vnd.createasyncreportrequest.v3+json' \\\n--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxx' \\\n--header 'Amazon-Advertising-API-Scope: xxxxxxxxx' \\\n--header 'Authorization: Bearer Atza|xxxxxxxxxx' \\\n--data '{\n    \"name\": \"SB campaigns report 9/5-9/10\",\n    \"startDate\": \"2023-09-05\",\n    \"endDate\": \"2023-09-10\",\n    \"configuration\": {\n        \"adProduct\": \"SPONSORED_BRANDS\",\n        \"groupBy\": [\n            \"campaign\"\n        ],\n        \"columns\": [\n            \"impressions\",\n            \"clicks\",\n            \"cost\",\n            \"campaignId\",\n            \"startDate\",\n            \"endDate\"\n        ],\n        \"reportTypeId\": \"sbCampaigns\",\n        \"timeUnit\": \"SUMMARY\",\n        \"format\": \"GZIP_JSON\"\n    }\n}'\n```\n\nFile v1.0.8:references/report-types/sb/sbGrossAndInvalids.md\n\n---\nreportTypeId: sbGrossAndInvalids\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/gross-and-invalid-traffic\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [campaign]\nformat: [GZIP_JSON, CSV]\nfilters:\n  - name: campaignStatus\n    values: [ENABLED, PAUSED, ARCHIVED]\n    applicableWhenGroupBy: [campaign]\ndateRange:\n  maxSpanDays: 365\n  dataRetentionDays: 365\n---\n\n# SB Gross and Invalid Traffic\n\nGross and invalid traffic report provides Sponsored Products, Sponsored Brands and Sponsored Display advertisers transparency into the nature of traffic on their campaigns. This report include all campaigns of the requested ad type and provides transparency on gross and invalid traffic metrics at campaign level for the requested days. For example, a Sponsored Products gross and invalid traffic report returns gross and invalid traffic metrics for all Sponsored Products campaigns that received impressions on the chosen dates.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbGrossAndInvalids |\n| Maximum date range | 365 days |\n| Data retention | 365 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | campaign |\n| format | GZIP_JSON or CSV |\n\n> Sponsored Products, Sponsored Brands, and Sponosred Display all support the same columns and configurations for the gross and invalid traffic report.\n\n## Base metrics\n\n| Field |\n|------|\n| campaignName |\n| campaignStatus |\n| clicks |\n| date |\n| endDate |\n| grossClickThroughs |\n| grossImpressions |\n| impressions |\n| invalidClickThroughRate |\n| invalidClickThroughs |\n| invalidImpressionRate |\n| invalidImpressions |\n| startDate |\n\n## Group by campaign\n\n**Additional metrics**: N/A\n\n**Filters**:\n- campaignStatus (values: ENABLED, PAUSED, ARCHIVED)\n\nFile v1.0.8:references/report-types/sb/sbPromptAdExtension.md\n\n---\nreportTypeId: sbPromptAdExtension\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/prompt-ad-extension\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [promptAdExtension]\nformat: [GZIP_JSON, XLSX]\nfilters:\n  - name: marketplaceId\n    values: [US]\n    applicableWhenGroupBy: [promptAdExtension]\ndateRange:\n  maxSpanDays: 90\n  dataRetentionDays: 95\n---\n\n# SB Prompt Ad Extension\n\nPrompt Ad Extension reports contain performance data for Sponsored Products and Sponsored Brands ads that include metrics for AI-powered prompt ads. Prompts are designed to help shoppers discover products through conversational experiences on Amazon by surfacing relevant product information through intelligent suggestions and guiding questions.\n\n## About Prompts\n\nPrompts are a new ad format that integrates into your existing Sponsored Products and Sponsored Brands campaigns with zero additional setup required. They enhance product discovery at crucial shopper decision points by:\n\n- Showcasing your product expertise at scale during critical shopper decision moments\n- Engaging high-intent shoppers with relevant product information\n- Anticipating and answering shopper questions about your products\n\nPrompts with clicks will show in your existing Sponsored Products or Sponsored Brands reporting, and you can pause individual prompts through the Amazon Ads console.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbPromptAdExtension |\n| Maximum date range | 90 days |\n| Data retention | 95 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | promptAdExtension |\n| format | GZIP_JSON or XLSX |\n\n## Base metrics\n\n| Field |\n|------|\n| date |\n| startDate |\n| endDate |\n| campaignId |\n| campaignName |\n| adGroupId |\n| adGroupName |\n| marketplaceId |\n| adId |\n| adName |\n| creativeExtensionId |\n| creativeExtensionType |\n| portfolioName |\n| campaignBudgetCurrencyCode |\n| promptText |\n| impressions |\n| clicks |\n| clickThroughRate |\n| costPerClick |\n| cost |\n| spend |\n| viewableImpressions |\n| acosClicks7d |\n| acosClicks14d |\n| roasClicks7d |\n| roasClicks14d |\n| purchases1d |\n| purchases7d |\n| purchases14d |\n| purchases30d |\n| purchasesSameSku1d |\n| purchasesSameSku7d |\n| purchasesSameSku14d |\n| purchasesSameSku30d |\n| purchasesOtherSku1d |\n| purchasesOtherSku7d |\n| purchasesOtherSku14d |\n| purchasesOtherSku30d |\n| unitsSoldClicks1d |\n| unitsSoldClicks7d |\n| unitsSoldClicks14d |\n| unitsSoldClicks30d |\n| unitsSoldSameSku1d |\n| unitsSoldSameSku7d |\n| unitsSoldSameSku14d |\n| unitsSoldSameSku30d |\n| unitsSoldOtherSku1d |\n| unitsSoldOtherSku7d |\n| unitsSoldOtherSku14d |\n| unitsSoldOtherSku30d |\n| sales1d |\n| sales7d |\n| sales14d |\n| sales30d |\n| attributedSalesSameSku1d |\n| attributedSalesSameSku7d |\n| attributedSalesSameSku14d |\n| attributedSalesSameSku30d |\n| salesOtherSku1d |\n| salesOtherSku7d |\n| salesOtherSku14d |\n| salesOtherSku30d |\n| purchaseClickRate7d |\n| purchaseClickRate14d |\n| newToBrandPurchases |\n| newToBrandPurchasesPercentage |\n| newToBrandUnitsSold |\n| newToBrandUnitsSoldPercentage |\n| newToBrandSales |\n| newToBrandSalesPercentage |\n\n## Group by promptAdExtension\n\n**Additional metrics**: N/A\n\n**Filters**:\n- marketplaceId (values: US)\n\n## Sample call\n\n```bash\ncurl --location 'https://advertising-api.amazon.com/reporting/reports' \\\n--header 'Content-Type: application/vnd.createasyncreportrequest.v3+json' \\\n--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxxxx' \\\n--header 'Amazon-Advertising-API-Scope: xxxxxxx' \\\n--header 'Authorization: Bearer Atza|xxxxxxxxxxx' \\\n--data '{\n    \"name\":\"SB prompt ad extension report 4/13-4/16\",\n    \"startDate\":\"2026-04-13\",\n    \"endDate\":\"2026-04-16\",\n    \"configuration\":{\n        \"adProduct\":\"SPONSORED_BRANDS\",\n        \"groupBy\":[\"promptAdExtension\"],\n        \"columns\":[\"date\",\"campaignId\",\"campaignName\",\"adGroupId\",\"adGroupName\",\"adId\",\"adName\",\"creativeExtensionId\",\"promptText\",\"impressions\",\"clicks\",\"cost\",\"purchases7d\",\"sales7d\",\"newToBrandPurchases\",\"newToBrandSales\"],\n        \"reportTypeId\":\"sbPromptAdExtension\",\n        \"timeUnit\":\"DAILY\",\n        \"format\":\"GZIP_JSON\"\n    }\n}'\n```\n\nArchive v1.0.7: 34 files, 72142 bytes\n\nFiles: references/api.md (10759b), references/onboarding.md (2046b), references/report-types/index.md (552b), references/report-types/sb/index.md (562b), references/report-types/sb/sbAdGroup.md (4001b), references/report-types/sb/sbAds.md (3314b), references/report-types/sb/sbCampaignPlacement.md (3673b), references/report-types/sb/sbCampaigns.md (4286b), references/report-types/sb/sbGrossAndInvalids.md (1786b), references/report-types/sb/sbPromptAdExtension.md (4170b), references/report-types/sb/sbPurchasedProduct.md (2262b), references/report-types/sb/sbSearchTerm.md (3788b), references/report-types/sb/sbTargeting.md (4330b), references/report-types/sd/index.md (426b), references/report-types/sd/sdAdGroup.md (3664b), references/report-types/sd/sdAdvertisedProduct.md (3473b), references/report-types/sd/sdCampaigns.md (3878b), references/report-types/sd/sdGrossAndInvalids.md (2544b), references/report-types/sd/sdPurchasedProduct.md (2742b), references/report-types/sd/sdTargeting.md (4672b), references/report-types/sp/index.md (494b), references/report-types/sp/spAdvertisedProduct.md (2794b), references/report-types/sp/spCampaigns.md (6362b), references/report-types/sp/spGrossAndInvalids.md (2747b), references/report-types/sp/spPromptAdExtension.md (3887b), references/report-types/sp/spPurchasedProduct.md (2869b), references/report-types/sp/spSearchTerm.md (4766b), references/report-types/sp/spTargeting.md (5365b), scripts/check_auth_dependency.py (6741b), scripts/get_report.py (32577b), scripts/onboarding.py (24089b), skill-card.md (3050b), SKILL.md (14301b), _meta.json (144b)\n\nFile v1.0.7:SKILL.md\n\n---\nname: linkfox-amazon-ads-report\ndescription: 亚马逊广告（Amazon Ads）报告一站式获取技能，覆盖 Sponsored Products (SP) / Sponsored Brands (SB) / Sponsored Display (SD) 全部报告类型。脚本自动完成报告的创建、等待、下载和解压，直接返回可读的结构化数据。真实可用的报告类型及每类的列清单/groupBy/filters 以 `references/report-types/<adProduct-dir>/<reportTypeId>.md` 为单一真相源。当用户提到拉取亚马逊广告报告、下载 Amazon Ads 报告、获取 SP/SB/SD 广告活动/关键词/搜索词/投放商品/购买商品/广告组/流量异常/Prompt 扩展等任意报告时触发。本技能依赖 linkfox-amazon-ads-auth。Sponsored Television (ST) / Amazon DSP 暂未覆盖。\n---\n\n# Amazon Ads 报告获取\n\n报告一站式获取：脚本经 `developerProxy` 传 `profileId`（服务端解析 token），自动完成报告的创建、等待（约 2–10 分钟）、下载和解压，直接返回可读的结构化数据。\n脚本本身不做\"该选哪些列 / 该怎么分组\"的业务判断，这些由 agent 先查 `references/report-types/` 下对应的 `.md` 文件，再显式传给脚本。\n\n**依赖 `linkfox-amazon-ads-auth`**（脚本启动自动检查；未安装时 exit 42，stderr 打 `DEPENDENCY_MISSING`）。\n\n### ⚠️ 多账号场景：调用前必须解析好 profileId\n\n用户经常只说自然语言（\"美国站\"、\"日本站\"、\"我的店铺\"），本 skill 的所有脚本都必须拿到数字 `profileId` 才能调。按下列顺序处理，**不要跳过**：\n\n1. 先调 `linkfox-amazon-ads-auth` 的 `authorized_stores.py` 拉出用户已授权的账号 × 站点清单。\n2. 根据用户提到的站点（映射到 `countryCode`，如 美国→`US`）匹配候选 profile：\n   - **只有 1 个候选** → 静默取对应 profileId，继续调用；不要把 profileId 数字播报给用户。\n   - **≥ 2 个候选（同站点下多个授权账号）** → **必须向用户澄清**，用 `accountName` 问：\"你在美国站授权了 A 和 B 两个账号，这次用哪个？\"\n   - **0 个候选** → 告知用户该站点未授权，引导去 `linkfox-amazon-ads-auth` 做授权。\n3. **严禁**让用户直接报 profileId 数字。\n4. **严禁**在歧义下\"挑第一个\"或\"选默认\"绕过澄清。\n\n完整决策表见 `linkfox-amazon-ads-auth` SKILL.md 的 **Usage Scenarios 第 4 节**。\n\n## 调用方式\n\n- **API 端点**：`POST /amazonAds/developerProxy`（不同操作通过请求体区分；完整参数/响应/错误码见 `references/api.md`）\n- **Python 脚本**：`python scripts/<脚本名>.py '<JSON 参数>' [--inline]`（可用脚本见上文脚本一览）\n- **成本约束**：本工具会消耗积分；失败/空结果不得自动换关键词、翻页或连续试探；需要继续检索时先向用户说明会产生额外消耗。\n\n**输出策略（脚本默认行为）**：\n- **始终**将完整响应写入 `<cwd>/linkfox/<YYYY-MM-DD>/<session>/data/<skill-name>-<timestamp>.json`（`<cwd>` 为脚本执行时的工作目录，在 Claude Code 里即当前项目目录；`<session>` 取自环境变量 `SESSION_ID`，按用户任务自动聚合；**禁止写入 /tmp**，当前目录不可写则报错）\n- 响应体 ≤ 8 KB：落盘后把完整 JSON 打印到 stdout\n- 响应体 > 8 KB：落盘后 stdout 只输出摘要（顶层字段、常见计数如 `total`/`costToken`、最大列表字段的长度 + 前 3 条样本）\n- 加 `--inline` 强制全量打印到 stdout（同样落盘）\n\n**读数据建议**：先看摘要判断是否足够；需要具体字段时优先用 `jq`或`ConvertFrom-Json`或`ConvertFrom-Json` 从保存的 json 文件按需抽取，避免整份 JSON 进入上下文。\n\n## 解决认证和积分问题\n发生以下异常情况时，采用 references/onboarding.md 引导解决问题：\n\n### 异常情况\n- **未配置API Key**：环境变量未配置 `LINKFOX_AGENT_API_KEY`，也未配置 `LINKFOXAGENT_API_KEY`。\n- **响应401或402状态码**\n- **响应提示积分或余额不足**：消息含\"积分余额不足/计费不足/余额不足/quota exceeded/insufficient balance/套餐到期/需充值/请充值\"，或类似含义的内容。\n\n## Core Concepts\n\n- **覆盖**：SP / SB / SD 全部报告类型（以 `references/report-types/` 下存在的 `.md` 为准；ST / DSP 暂未覆盖）\n- **一站式**：脚本内部自动完成报告创建 → 等待生成（约 2–10 分钟）→ 下载 → 解压，调用方只需等最终结果\n- **单脚本**：`get_report.py`（覆盖 SP / SB 全部 adProduct）\n- **元数据 vs. 运行参数**：\n  - 每个报告类型的**可用字段**（timeUnit / groupBy / filters / 全部列名）集中在 `references/report-types/<adProduct-dir>/<reportTypeId>.md`\n  - **脚本运行参数**（等待间隔、访问链接时效等）见本文件和 `references/api.md`\n\n## 可用脚本\n\n| 脚本 | 职责 |\n|------|------|\n| `get_report.py` ⭐ | 一站式执行。**必填** `adProduct` / `groupBy` / `columns`，由 agent 从 report-types/ 提取后传入 |\n| `check_auth_dependency.py` | 检测 linkfox-amazon-ads-auth 是否安装 |\n\n完整脚本参数、响应结构见 `references/api.md`。\n\n## Agent 调用流程\n\nAgent 触达\"拉取亚马逊广告报告\"类需求时，**必须**按下列顺序：\n\n1. **定 reportTypeId**：按用户意图挑选（如\"上周花费\"→ `spCampaigns`；\"哪个商品卖得好\"→ `spAdvertisedProduct` / `sbPurchasedProduct`；\"用户搜什么词找到我\"→ `spSearchTerm`）\n2. **查 reference**：打开 `references/report-types/<adProduct-dir>/<reportTypeId>.md`\n   - **frontmatter** 给出：`adProduct` / `groupBy`（Configuration 表推荐的） / `timeUnit`(可枚举) / `format` / `dateRange` / `filters`\n   - **Base metrics 表** 给出：此报告类型允许的全部列名\n3. **向用户咨询可定制条件**（用户答\"默认/随便\"时跳过，进入第 4 步的默认选择）：\n   - `timeUnit`：DAILY（按日拆分）还是 SUMMARY（汇总）\n   - `columns` 扩展：是否要归因列（sales7d / purchases7d / acosClicks7d / roasClicks7d）、视频指标、newToBrand 等\n   - `filters`：是否过滤 campaignStatus / keywordType / adStatus 等\n4. **按用户回复或默认构造 columns**（见下节 \"默认条件\"）\n5. **调脚本**：`adProduct` / `groupBy` / `columns` 三个必填字段**显式**传入\n\n## 默认条件（用户未指定时使用）\n\n| 条件 | 默认规则 |\n|------|---------|\n| `timeUnit` | 日期跨度 ≤ 7 天 → `DAILY`；> 7 天 → `SUMMARY` |\n| `columns` 身份维度 | `DAILY` 时必含 `date`；`SUMMARY` 时必含 `startDate` + `endDate`；再追加该报告的主键字段（参考 frontmatter 中 groupBy 对应的主键，如 campaignId+campaignName / advertisedAsin+advertisedSku / searchTerm / keyword 等） |\n| `columns` 基础指标 | `impressions` / `clicks` / `cost`（以该报告 Base metrics 存在的为准） |\n| `columns` 归因指标 | **仅当用户提到\"销售/转化/ROI/ACOS\"等意图时追加**：`sales7d` / `purchases7d` / `acosClicks7d` / `roasClicks7d`（以 Base metrics 存在者为准） |\n| `filters` | 不加（全量返回） |\n| `groupBy` | 取 frontmatter `groupBy` 数组的第一个值（即 Configuration 表里 Amazon 官方推荐的主维度） |\n\n## 请求示例\n\n所有 example 都显式传入三个必填字段（`adProduct` / `groupBy` / `columns`）。\n\n### 1. SP 广告活动报告（最常见）\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"adProduct\": \"SPONSORED_PRODUCTS\",\n  \"groupBy\": [\"campaign\"],\n  \"columns\": [\"date\",\"campaignId\",\"campaignName\",\"impressions\",\"clicks\",\"cost\"],\n  \"startDate\": \"2026-04-27\",\"endDate\": \"2026-05-03\",\n  \"timeUnit\": \"DAILY\"\n}'\n```\n\n### 2. SP 搜索词报告（含归因）\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"spSearchTerm\",\n  \"adProduct\": \"SPONSORED_PRODUCTS\",\n  \"groupBy\": [\"searchTerm\"],\n  \"columns\": [\"searchTerm\",\"keyword\",\"matchType\",\"impressions\",\"clicks\",\"cost\",\n              \"sales7d\",\"sales14d\",\"purchases7d\",\"acosClicks14d\",\"roasClicks14d\",\n              \"startDate\",\"endDate\"],\n  \"startDate\": \"2026-04-01\",\"endDate\": \"2026-04-30\",\n  \"timeUnit\": \"SUMMARY\",\n  \"filters\": [{\"field\":\"keywordType\",\"values\":[\"BROAD\",\"PHRASE\",\"EXACT\"]}]\n}'\n```\n\n### 3. SB 广告组报告\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"sbAdGroup\",\n  \"adProduct\": \"SPONSORED_BRANDS\",\n  \"groupBy\": [\"adGroup\"],\n  \"columns\": [\"adGroupId\",\"adGroupName\",\"impressions\",\"clicks\",\"cost\",\"purchases\",\"sales\",\"startDate\",\"endDate\"],\n  \"startDate\": \"2026-04-01\",\"endDate\": \"2026-04-30\"\n}'\n```\n\n### 4. SD 广告活动报告\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"sdCampaigns\",\n  \"adProduct\": \"SPONSORED_DISPLAY\",\n  \"groupBy\": [\"campaign\"],\n  \"columns\": [\"date\",\"campaignId\",\"campaignName\",\"impressions\",\"clicks\",\"cost\",\"purchases\",\"sales\"],\n  \"startDate\": \"2026-04-27\",\"endDate\": \"2026-05-03\",\n  \"timeUnit\": \"DAILY\"\n}'\n```\n\n### 5. 轮询一个已有 reportId（救回上次超时 / 手工恢复）\n\n当上次运行因为客户端轮询窗口太短退出、但报告在 Amazon 侧仍在跑时，直接传入 `reportId` 即可跳过创建，继续轮询并下载。此模式下只需 `profileId` / `region` / `reportId`，其余字段不必填。\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportId\": \"7df1ef5d-45ba-40cc-b607-ff2148cf4f5e\",\n  \"maxAttempts\": 60, \"pollInterval\": 30\n}'\n```\n\n> **自动恢复**：如果调用方未传 `reportId`、且 Amazon 对同参数请求触发去重（返回 HTTP 425 `The Request is a duplicate of : <uuid>`），脚本会自动解析出老 reportId 并转为轮询该老报告，无需重试。\n\n## 响应格式\n\n成功：\n```json\n{\n  \"success\": true,\n  \"reportId\": \"4ee811a0-...\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"startDate\": \"2026-04-28\", \"endDate\": \"2026-05-04\",\n  \"downloadPath\": \"C:/.../tmp/report_data.json\",\n  \"extractedFileHttpUrl\": \"http://127.0.0.1:51234/download\",\n  \"extractedFileHttpServeSeconds\": 300\n}\n```\n\n失败：\n```json\n{\"error\":\"Upstream HTTP 400\",\"httpStatus\":400,\n \"body\":\"{\\\"code\\\":\\\"400\\\",\\\"detail\\\":\\\"startDate to endDate range (32 days) must not exceed maximum range (31 days)\\\"}\"}\n```\n\n## 调用原则\n\n- 用户指定了 reportTypeId 就只拉那一种，不擅自替换\n- 报告失败（非 2xx 或 status=FAILED）时如实告知错误原因，不盲目重试\n- 成功后把报告的本地文件路径和访问链接完整展示给用户，并提醒访问链接有时效（默认 5 分钟内有效，过期需重新拉取）\n- **超时不是失败**：当脚本返回 `status=STILL_PROCESSING`（exit code=2），说明客户端已等满默认 10 分钟但报告仍在 Amazon 侧生成。此时 **必须**向用户说明情况并询问是否继续等待，绝不能当成失败处理。参考回复：\"报告还在 Amazon 侧生成中（已等 10 分钟），要继续等吗？可以选：A. 再等 ~20 分钟（maxAttempts=60）、B. 再等 ~1 小时（maxAttempts=120）、C. 先停，我稍后用 reportId 回来。\" 用户选 A/B → 用 `resumeHint.params` 切到仅轮询模式续跑\n\n## 常见错误\n\n| 状态 | 含义 | 建议 |\n|------|------|------|\n| `Missing required parameters: adProduct/groupBy/columns` | 调用方未显式传入三必填 | 回到 \"Agent 调用流程\" 第 2 步，从 `references/report-types/<adProduct-dir>/<reportTypeId>.md` 读出并补上 |\n| `HTTP 401` | accessToken 过期 | 调 ads-auth 的 `refresh_token.py` 后重试 |\n| `HTTP 403` | 未关联广告账户或权限不足 | 到 Amazon Ads 后台检查经理账户/广告账户关联 |\n| `HTTP 400 \"must not exceed maximum range\"` | 日期跨度超限（多数 31 天） | 拆分拉取后本地合并；具体上限看对应 `.md` frontmatter `dateRange.maxSpanDays` |\n| `HTTP 400` 含 `columns`/`groupBy` 校验错 | 列名拼写错 / 与 reportTypeId 不匹配 / 超出 Base metrics | 对照 `.md` 文件 Base metrics 表核对 |\n| `status=FAILED` 含 `failureReason` | 上游生成失败 | 多为日期窗口或权限问题，按 failureReason 具体处理 |\n| `status=STILL_PROCESSING` (exit 2) | 客户端轮询窗口耗尽但报告仍在生成 | **不是失败**。stdout 已含 `reportId` 与 `resumeHint.params`。询问用户是否继续等，用该 params（带 `reportId` + 更大 `maxAttempts`）切到仅轮询模式续跑 |\n| `HTTP 425 \"duplicate of\"` | 同参数已有在跑的报告 | 脚本自动解析并转为轮询该老 reportId，正常情况下调用方无需干预 |\n| exit 42 | 依赖 skill 未安装 | 先装 `linkfox-amazon-ads-auth` |\n\n## 日期与数据\n\n- **日期跨度上限**：多数报告 31 天；`sbPurchasedProduct` 是 731 天；`spGrossAndInvalids` / `sbGrossAndInvalids` / `sdGrossAndInvalids` 是 365 天（以 frontmatter 为准）\n- **回溯窗口**：SP 默认 95 天、SB 60 天、GrossAndInvalids 365 天；具体以 frontmatter `dateRange.dataRetentionDays` 为准\n- **数据延迟约 12 小时**；`endDate >= 今天` 脚本 stderr 警告但不拦截\n- **空数据不等于报错**：账号当期无投放时报告会成功生成，JSON 可能为 `[]` 或指标全 0\n\n## Not Applicable\n\n- Brand Analytics / Retail Analytics / Attribution 报告 → 不在本 skill\n- 报告删除 / 修改 / 定时任务 → 不在本 skill\n- 实体元数据（campaign 名、keyword 匹配类型等）→ `linkfox-amazon-ads-manager`\n- 授权 / token → `linkfox-amazon-ads-auth`\n\n## 积分消耗规则\n\n不消耗积分。\n\n**Feedback:**\n\nAuto-detect and report feedback via the Feedback API when any of the following apply:\n1. The functionality or purpose described in this skill does not match actual behavior\n2. The skill's results do not match the user's intent\n3. The user expresses dissatisfaction or praise about this skill\n4. Anything you believe could be improved\n\nCall the feedback API as specified in `references/api.md`. Do not interrupt the user's flow.\n\n---\n*For more high-quality, professional cross-border e-commerce skills, visit [LinkFox Skills](https://skill.linkfox.com/).*\n\nFile v1.0.7:_meta.json\n\n{\n  \"ownerId\": \"kn7dmc1t4j28hem1twwyav85p182pb1j\",\n  \"slug\": \"linkfox-amazon-ads-report\",\n  \"version\": \"1.0.7\",\n  \"publishedAt\": 1786718555338\n}\n\nFile v1.0.7:references/api.md\n\n# linkfox-amazon-ads-report — 参数与字段参考\n\nAmazon Ads 报告自动化获取（SP / SB 覆盖；SD / ST / DSP 暂未覆盖）。授权见 `linkfox-amazon-ads-auth`；广告管理见 `linkfox-amazon-ads-manager`。\n\n> **📌 报告类型的真相源**：每个 `reportTypeId` 的完整规格（可用 columns / groupBy / filters / timeUnit / 日期约束 / 官方示例）在 `references/report-types/<adProduct-dir>/<reportTypeId>.md`，**按 adProduct 分目录**：\n> - `report-types/sp/`（Sponsored Products）\n> - `report-types/sb/`（Sponsored Brands）\n>\n> 目录总览见 `report-types/index.md`。本文件仅给运行时脚本参数与通用规则。\n\n## 支持的报告类型\n\n完整列表见 `report-types/index.md` 及各 adProduct 子目录下的 `index.md`。常用快速索引：\n\n| reportTypeId | 业务含义 | 文件 |\n|--------------|---------|------|\n| `spCampaigns` | 广告活动级（SP） | `report-types/sp/spCampaigns.md` |\n| `spAdvertisedProduct` | 投放商品级（SP） | `report-types/sp/spAdvertisedProduct.md` |\n| `spSearchTerm` | 搜索词级（SP） | `report-types/sp/spSearchTerm.md` |\n| `spTargeting` | 定向/关键词级（SP） | `report-types/sp/spTargeting.md` |\n| `sbCampaigns` / `sbAdGroup` / `sbAds` / ... | Sponsored Brands | `report-types/sb/*.md` |\n\n## 输入参数\n\n脚本支持两种模式：\n\n- **全链路模式（默认）**：创建报告 → 轮询 → 下载。需要下表全部必填字段。\n- **仅轮询模式**：入参中显式传入 `reportId`（见下方\"可选流程参数\"），跳过创建，只需 `profileId` / `region`，其余全部可省略。用于救回上次客户端超时但报告仍在跑的场景。\n\n### 必填（全链路模式）\n\n| 参数 | 类型 | 说明 |\n|------|------|------|\n| `profileId` | number | 从 ads-auth 获取 |\n| `region` | string | `NA` / `EU` / `FE` |\n| `reportTypeId` | string | 见 `report-types/index.md` 各 adProduct 子目录下的完整列表 |\n| `adProduct` | string | 取自对应 `.md` 文件的 frontmatter（`SPONSORED_PRODUCTS` / `SPONSORED_BRANDS`）|\n| `groupBy` | list | 取自对应 `.md` 文件的 frontmatter |\n| `columns` | list | 取自对应 `.md` 文件 Base metrics 表的子集 |\n| `startDate` | string | `YYYY-MM-DD`（含当天） |\n| `endDate` | string | `YYYY-MM-DD`（含当天） |\n\n### 可选业务参数\n\n| 参数 | 默认 | 说明 |\n|------|------|------|\n| `name` | `{reportTypeId}_{startDate}_{endDate}` | 报告显示名 |\n| `timeUnit` | `SUMMARY` | `DAILY`（每天一行） / `SUMMARY`（整期一行） |\n| `format` | `GZIP_JSON` | 响应文件格式 |\n| `filters` | 空 | 过滤条件数组，字段与取值见对应 `.md` 文件 |\n\n### 可选流程参数\n\n| 参数 | 默认 | 说明 |\n|------|------|------|\n| `reportId` | 无 | 若显式传入，脚本进入**仅轮询模式**：跳过创建步骤，直接对该 reportId 轮询与下载。此时只要 `profileId` / `region` + `reportId`，其他字段可省 |\n| `pollInterval` | 30 | 轮询间隔秒 |\n| `maxAttempts` | 20 | 最大轮询次数（默认 10 分钟上限） |\n| `skipDepCheck` | false | 跳过依赖检查 |\n| `serveExtractedFileHttp` | true | 是否启本机 HTTP 服务 |\n| `serveHost` | `127.0.0.1` | 绑定地址（仅本机可访问） |\n| `servePort` | 0 | 端口（0=系统分配） |\n| `serveSeconds` | 300 | HTTP 服务存活秒 |\n| `includeAmazonSourceUrl` | false | 响应中带预签名 URL |\n\n## 日期限制\n\n- **跨度上限**：以对应 `.md` 文件 frontmatter 的 `dateRange.maxSpanDays` 为准（多数 31 天；`sbPurchasedProduct` 731 天；GrossAndInvalids 系列 365 天）。超出返回 HTTP 400 `\"must not exceed maximum range\"`。\n- **回溯上限**：以 `dateRange.dataRetentionDays` 为准（SP 多为 95 天，SB 60 天）。\n- **数据延迟**：~12 小时；`endDate >= 今天` 脚本会 stderr 警告但不拦截。建议 `endDate <= 昨天`。\n\n## 各报告类型的列\n\n每个 reportTypeId 的完整 Base metrics 列表、allowed groupBy、filters 枚举值，统一在 `report-types/<adProduct-dir>/<reportTypeId>.md` 中维护：\n\n- `.md` 的 **frontmatter** 提供 `adProduct` / `groupBy` / `timeUnit`（可选值）/ `format` / `filters` / `dateRange`\n- **Base metrics 表**列出此报告类型支持的**全部列名**；调用方按业务需要选子集\n\n归因窗口后缀约定：`_1d` / `_7d` / `_14d` / `_30d` 表示 1/7/14/30 天归因窗口（点击或曝光归因的销售额、订单量、件数等）。具体每个字段支持哪些窗口，以对应 `.md` 文件的 Base metrics 表为准（不是所有字段都有全部 4 个窗口版本）。\n\n## 工作流与输出\n\n脚本流程：依赖检查 → 取 token → 创建报告 → 等待生成（每 `pollInterval` 秒查询一次状态）→ 下载 GZIP_JSON（Amazon 预签名 URL 约 1 小时有效）→ 解压为可读 JSON → 通过本机 `127.0.0.1` 上的临时 HTTP 服务对调用方暴露（`serveSeconds` 后自动关闭）→ 输出调用结果 JSON（含本地文件路径与访问链接）。\n\n`status` 枚举：`PENDING` / `PROCESSING` / `COMPLETED` / `FAILED`。\n\n### 成功响应\n\n```json\n{\n  \"success\": true,\n  \"reportId\": \"4ee811a0-6aaa-4ceb-9d31-d3bcecf85430\",\n  \"status\": \"COMPLETED\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"startDate\": \"2026-04-28\", \"endDate\": \"2026-05-04\",\n  \"pollAttempts\": 13, \"elapsedSeconds\": 255,\n  \"downloadPath\": \"C:/.../tmp/report-xxx.json\",\n  \"extractedFileHttpUrl\": \"http://127.0.0.1:51234/report-xxx.json\",\n  \"serveExpiresAt\": \"2026-05-06T14:54:03+08:00\"\n}\n```\n\n### 失败响应\n\n**a) 创建阶段非 2xx**：\n```json\n{\"error\":\"Upstream HTTP 400\",\"httpStatus\":400,\n \"body\":\"{\\\"code\\\":\\\"400\\\",\\\"detail\\\":\\\"startDate to endDate range (32 days) must not exceed maximum range (31 days)\\\"}\"}\n```\n\n**b) 报告生成失败**（`failureReason` 从上游透传）：\n```json\n{\"success\":false,\"error\":\"Report generation failed with status=FAILED\",\n \"reportId\":\"4ee811a0-...\",\"status\":\"FAILED\",\n \"failureReason\":\"Requested columns are not supported for this report type.\",\n \"pollAttempts\":3}\n```\n\n**c) 轮询超时**（报告未坏，仅客户端等待窗口耗尽 — **exit code = 2**）：\n```json\n{\n  \"success\": false,\n  \"status\": \"STILL_PROCESSING\",\n  \"reportId\": \"4ee811a0-...\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"profileId\": 1234567890,\n  \"lastStatus\": \"PROCESSING\",\n  \"pollAttempts\": 20,\n  \"elapsedSeconds\": 600,\n  \"message\": \"客户端已等 ~600 秒（20 次轮询）报告仍在 Amazon 侧生成，并未失败。用 reportId 切换到仅轮询模式即可继续等待。\",\n  \"resumeHint\": {\n    \"mode\": \"poll-only\",\n    \"note\": \"传入 reportId + 更大的 maxAttempts 继续轮询同一份报告\",\n    \"params\": {\"profileId\": 1234567890, \"region\": \"NA\", \"reportId\": \"4ee811a0-...\", \"maxAttempts\": 60, \"pollInterval\": 30}\n  }\n}\n```\n\n调用方收到此响应应视为\"未完成\"而非\"失败\"，询问用户是否继续等待，直接把 `resumeHint.params` 作为入参续调 `get_report.py`。\n\n## 错误码\n\n| httpStatus / exit | 含义 | 建议 |\n|-------------------|------|------|\n| 200 | 成功 | 消费 `extractedFileHttpUrl` 或 `downloadPath` |\n| 400 | 入参错（日期超限 / reportTypeId 非法 / columns 不适配） | 按 `detail` 修正 |\n| 401 | accessToken 过期 | HTTP 401 或 authorized error：按 SKILL.md 的 **## 解决认证和积分问题** 处理。 |\n| 402 | 积分或余额不足 | HTTP 402：按 SKILL.md 的 **## 解决认证和积分问题** 处理。 |\n| 403 | profileId 无权限 | 核对 profileId |\n| 404 | reportId 不存在或已过期 | 重新发起报告 |\n| 422 | columns / groupBy 与 reportTypeId 不适配 | 对照 `report-types/<adProduct-dir>/<reportTypeId>.md` 的 Base metrics / frontmatter 核对 |\n| 425 | 同参数已有在跑的报告，Amazon 做了去重；body 形如 `\"The Request is a duplicate of : <reportId>\"` | **脚本自动解析该 reportId 并无缝转为轮询该老报告**，正常情况下无需干预；若调用方自行处理，也可把 reportId 拿出来，下次改用仅轮询模式（`{..., \"reportId\":\"<uuid>\"}`） |\n| 429 | 限流（~30 req/min/profile） | 间隔 30s 重试 |\n| `status=FAILED` | 上游生成失败 | 看 `failureReason` |\n| `status=STILL_PROCESSING` (exit 2) | 客户端轮询窗口耗尽但报告仍在 Amazon 侧生成 | **非失败**。stdout 已输出 `reportId` 与 `resumeHint.params`。询问用户是否继续等，用 params 切到仅轮询模式续跑（maxAttempts=60 约 30 分钟 / =120 约 1 小时） |\n| exit 42 | 依赖 skill 未安装 | 先装 `linkfox-amazon-ads-auth` |\n\n## 调用示例\n\n```bash\n# 1. SP 广告活动汇总（DAILY，一周）\npython get_report.py '{\"profileId\":1111111111,\"region\":\"NA\",\n  \"reportTypeId\":\"spCampaigns\",\n  \"adProduct\":\"SPONSORED_PRODUCTS\",\n  \"groupBy\":[\"campaign\"],\n  \"columns\":[\"date\",\"campaignId\",\"campaignName\",\"impressions\",\"clicks\",\"cost\"],\n  \"startDate\":\"2026-04-27\",\"endDate\":\"2026-05-03\",\n  \"timeUnit\":\"DAILY\"}'\n\n# 2. SP 搜索词 + 多归因窗口 + 过滤仅看关键词匹配\npython get_report.py '{\"profileId\":1111111111,\"region\":\"NA\",\n  \"reportTypeId\":\"spSearchTerm\",\n  \"adProduct\":\"SPONSORED_PRODUCTS\",\n  \"groupBy\":[\"searchTerm\"],\n  \"columns\":[\"searchTerm\",\"keyword\",\"matchType\",\"impressions\",\"clicks\",\"cost\",\n             \"sales7d\",\"sales14d\",\"sales30d\",\n             \"purchases7d\",\"purchases14d\",\"purchases30d\",\n             \"acosClicks14d\",\"roasClicks14d\",\"startDate\",\"endDate\"],\n  \"startDate\":\"2026-04-01\",\"endDate\":\"2026-04-30\",\n  \"timeUnit\":\"SUMMARY\",\n  \"filters\":[{\"field\":\"keywordType\",\"values\":[\"BROAD\",\"PHRASE\",\"EXACT\"]}]}'\n\n# 3. SP 投放商品 + 长时间等待 + 不启本机 HTTP\npython get_report.py '{\"profileId\":1111111111,\"region\":\"NA\",\n  \"reportTypeId\":\"spAdvertisedProduct\",\n  \"adProduct\":\"SPONSORED_PRODUCTS\",\n  \"groupBy\":[\"advertiser\"],\n  \"columns\":[\"advertisedAsin\",\"advertisedSku\",\"impressions\",\"clicks\",\"cost\",\n             \"sales7d\",\"acosClicks7d\",\"roasClicks7d\",\"startDate\",\"endDate\"],\n  \"startDate\":\"2026-04-01\",\"endDate\":\"2026-04-30\",\n  \"timeUnit\":\"SUMMARY\",\n  \"maxAttempts\":60,\"pollInterval\":20,\"serveExtractedFileHttp\":false}'\n\n# 4. 仅轮询一个已有 reportId（救回上次超时）\npython get_report.py '{\"profileId\":1111111111,\"region\":\"NA\",\n  \"reportId\":\"7df1ef5d-45ba-40cc-b607-ff2148cf4f5e\",\n  \"maxAttempts\":60,\"pollInterval\":30}'\n```\n\n---\n\n## Feedback API\n\n与上面的工具 API **base URL 不同**：\n\n```bash\ncurl -X POST https://skill-api.linkfox.com/api/v1/public/feedback \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"skillName\":\"linkfox-amazon-ads-report\",\"sentiment\":\"POSITIVE\",\n       \"category\":\"OTHER\",\"content\":\"报告拉取顺利\"}'\n```\n\n- `sentiment`: `POSITIVE` / `NEUTRAL` / `NEGATIVE`\n- `category`: `BUG` / `COMPLAINT` / `SUGGESTION` / `OTHER`\n\nFile v1.0.7:references/onboarding.md\n\n# 解决认证和积分问题\n\n调用本 skill 时若网关返回 **auth** 或 **billing** 错误，走本 skill 自带的 `scripts/onboarding.py` 完成引导。\n\n**auth 场景**：`errcode=401` 或消息含 `authorized error`/`鉴权失败`/`未授权`/`unauthorized`；或 `LINKFOX_AGENT_API_KEY` 与 `LINKFOXAGENT_API_KEY` 均为空。\n1. 若已配置 key → 先让用户重启会话（最常见误判），仍失败让用户重新取 key 或换手机号重注册\n2. 未配置 → 询问：自助去 https://agent.linkfox.com/ 取 key，或提供手机号让脚本注册\n3. 手机号路径：\n   - `python scripts/onboarding.py send-code <phone>` → 展示 JSON 里的 phone/agreements\n   - 收到验证码后：`python scripts/onboarding.py login <phone> <code>`（workbuddy 宿主加 `--channel workbuddy`）\n   - 拿到 `api_key` 后把下面三平台配置转发给用户，提示重启会话生效：\n     - Windows PowerShell（永久）：`setx LINKFOX_AGENT_API_KEY \"<key>\"`\n     - macOS zsh：`echo 'export LINKFOX_AGENT_API_KEY=\"<key>\"' >> ~/.zshrc && source ~/.zshrc`\n     - Linux bash：`echo 'export LINKFOX_AGENT_API_KEY=\"<key>\"' >> ~/.bashrc && source ~/.bashrc`\n     - 变量名 `LINKFOX_AGENT_API_KEY`（主推）或 `LINKFOXAGENT_API_KEY`（老规范）任一即可\n\n**billing 场景**：`errcode=402` 或消息含 `积分/余额/quota/insufficient/充值/套餐到期`。\n- `python scripts/onboarding.py list-plans` → 有 AskUserQuestion 就弹菜单，否则输出编号清单让用户选\n- 校验 `plan_id` ∈ 清单、支付方式 ∈ 该套餐 `available_methods`（通常 `wechat/alipay`）\n- `python scripts/onboarding.py order <plan_id> <method>` → 展示优先级 PNG > `pay_url` > `ascii_qr`（标注兜底）\n- 已付款可选调 `python scripts/onboarding.py query <order_id>`，不主动轮询\n\n排除 `errcode=403`（无权限，不归入这两类）。所有子命令输出 stdout JSON，`error` 字段已含阶段前缀，透传给用户即可。完整用法：`python scripts/onboarding.py --help`。\n\nFile v1.0.7:references/report-types/index.md\n\n# Amazon Ads Report Types\n\n按 `adProduct` 分类。每个 `.md` 文件名即 `reportTypeId`，内容为官方原文 + YAML frontmatter 结构化字段，用于构造 `POST /reporting/reports` 请求体。\n\n## 目录\n\n| adProduct | 目录 |\n|-----------|------|\n| SPONSORED_PRODUCTS | [`sp/`](./sp/) |\n| SPONSORED_BRANDS | [`sb/`](./sb/) |\n| SPONSORED_DISPLAY | [`sd/`](./sd/) |\n\n> Sponsored Television (ST) / Amazon DSP 暂未覆盖，后续版本支持。\n\n## 数据源\n\nhttps://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types\n\nFile v1.0.7:references/report-types/sb/index.md\n\n# Sponsored Brands (SB) Report Types\n\n`adProduct = SPONSORED_BRANDS`\n\n| reportTypeId | 状态 |\n|--------------|------|\n| [`sbAdGroup`](./sbAdGroup.md) | ✅ |\n| [`sbAds`](./sbAds.md) | ✅ |\n| [`sbCampaigns`](./sbCampaigns.md) | ✅ |\n| [`sbCampaignPlacement`](./sbCampaignPlacement.md) | ✅ |\n| [`sbGrossAndInvalids`](./sbGrossAndInvalids.md) | ✅ |\n| [`sbPromptAdExtension`](./sbPromptAdExtension.md) | ✅ |\n| [`sbPurchasedProduct`](./sbPurchasedProduct.md) | ✅ |\n| [`sbSearchTerm`](./sbSearchTerm.md) | ✅ |\n| [`sbTargeting`](./sbTargeting.md) | ✅ |\n\nFile v1.0.7:references/report-types/sb/sbAdGroup.md\n\n---\nreportTypeId: sbAdGroup\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/ad-group\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [adGroup]\nformat: [GZIP_JSON]\nfilters:\n  - name: adStatus\n    values: [ENABLED, PAUSED, ARCHIVED]\n    applicableWhenGroupBy: [adGroup]\ndateRange:\n  maxSpanDays: 31\n  dataRetentionDays: 60\n---\n\n# SB Ad Group\n\nAd group reports contain performance data broken down at the ad group level. Ad group reports include all campaigns of the requested sponsored ad type that have performance activity for the requested days. For example, a Sponsored Brands ad group report returns performance data for all Sponsored Brands ad groups that received impressions on the chosen dates.\n\n> **Note**\n> For Sponsored Products, there is not a separate ad group report. You can get ad group-level data using the ad group groupBy in a campaign report.\n\n> **Note**\n> This report currently available in preview. During the preview period, data related to Sponsored Brands campaigns with flag isMultiAdGroupsEnabled=False won't be available. Once version 3 reporting supports all Sponsored Brands campaigns, we will announce general availability in the release notes.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbAdGroup |\n| Maximum date range | 31 days |\n| Data retention | 60 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | adGroup |\n| format | GZIP_JSON |\n\n## Base metrics\n\n| Field |\n|------|\n| addToCart |\n| addToCartClicks |\n| addToCartRate |\n| adGroupId |\n| adGroupName |\n| adStatus |\n| addToList |\n| addToListFromClicks |\n| qualifiedBorrows |\n| qualifiedBorrowsFromClicks |\n| royaltyQualifiedBorrows |\n| royaltyQualifiedBorrowsFromClicks |\n| brandedSearches |\n| brandedSearchesClicks |\n| campaignBudgetAmount |\n| campaignBudgetCurrencyCode |\n| campaignBudgetType |\n| campaignId |\n| campaignName |\n| campaignStatus |\n| clicks |\n| cost |\n| costType |\n| date |\n| detailPageViews |\n| detailPageViewsClicks |\n| eCPAddToCart |\n| endDate |\n| impressions |\n| kindleEditionNormalizedPagesRead14d |\n| kindleEditionNormalizedPagesRoyalties14d |\n| newToBrandDetailPageViewRate |\n| newToBrandDetailPageViews |\n| newToBrandDetailPageViewsClicks |\n| newToBrandECPDetailPageView |\n| newToBrandPurchases |\n| newToBrandPurchasesClicks |\n| newToBrandPurchasesPercentage |\n| newToBrandPurchasesRate |\n| newToBrandSales |\n| newToBrandSalesClicks |\n| newToBrandSalesPercentage |\n| newToBrandUnitsSold |\n| newToBrandUnitsSoldClicks |\n| newToBrandUnitsSoldPercentage |\n| purchases |\n| purchasesClicks |\n| purchasesPromoted |\n| sales |\n| salesClicks |\n| salesPromoted |\n| startDate |\n| unitsSold |\n| unitsSoldClicks |\n| video5SecondViewRate |\n| video5SecondViews |\n| videoCompleteViews |\n| videoFirstQuartileViews |\n| videoMidpointViews |\n| videoThirdQuartileViews |\n| videoUnmutes |\n| viewabilityRate |\n\n## Group by adGroup\n\n**Additional metrics**: N/A\n\n**Filters**:\n- adStatus (values: ENABLED, PAUSED, ARCHIVED)\n\n## Group by campaign\n\n**Additional metrics**: N/A\n\n## Sample call\n\n### Ad group summary report grouped by ad group\n\n```bash\ncurl --location 'https://advertising-api.amazon.com/reporting/reports' \\\n--header 'Content-Type: application/vnd.createasyncreportrequest.v3+json' \\\n--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxx' \\\n--header 'Amazon-Advertising-API-Scope: xxxxxxxx' \\\n--header 'Authorization: Bearer Atza|xxxxxxxxxxx' \\\n--data '{\n    \"name\": \"SB ad group report 9/5-9/10\",\n    \"startDate\": \"2023-09-05\",\n    \"endDate\": \"2023-09-10\",\n    \"configuration\": {\n        \"adProduct\": \"SPONSORED_BRANDS\",\n        \"groupBy\": [\n            \"adGroup\"\n        ],\n        \"columns\": [\n            \"impressions\",\n            \"clicks\",\n            \"cost\",\n            \"campaignId\",\n            \"adGroupId\",\n            \"startDate\",\n            \"endDate\"\n        ],\n        \"reportTypeId\": \"sbAdGroup\",\n        \"timeUnit\": \"SUMMARY\",\n        \"format\": \"GZIP_JSON\"\n    }\n}'\n```\n\nFile v1.0.7:references/report-types/sb/sbAds.md\n\n---\nreportTypeId: sbAds\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/ad\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [ads]\nformat: [GZIP_JSON]\nfilters:\n  - name: adStatus\n    values: [ENABLED, PAUSED, ARCHIVED]\n    applicableWhenGroupBy: [ads]\ndateRange:\n  maxSpanDays: 31\n  dataRetentionDays: 60\n---\n\n# SB Ads\n\nAdvertised product reports contain performance data for campaigns at the ad level.\n\n> **Note**\n> This report is currently available in preview. During the preview period, data related to Sponsored Brands campaigns with flag isMultiAdGroupsEnabled set to FALSE won't be available. Once version 3 reporting supports all Sponsored Brands campaigns, we will announce general availability in the release notes.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbAds |\n| Maximum date range | 31 days |\n| Data retention | 60 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | ads |\n| format | GZIP_JSON |\n\n## Base metrics\n\n| Field |\n|------|\n| addToCart |\n| addToCartClicks |\n| addToCartRate |\n| addToList |\n| qualifiedBorrows |\n| royaltyQualifiedBorrows |\n| addToListFromClicks |\n| qualifiedBorrowsFromClicks |\n| royaltyQualifiedBorrowsFromClicks |\n| adGroupId |\n| adGroupName |\n| adId |\n| brandedSearches |\n| brandedSearchesClicks |\n| campaignBudgetAmount |\n| campaignBudgetCurrencyCode |\n| campaignBudgetType |\n| campaignId |\n| campaignName |\n| campaignStatus |\n| clicks |\n| cost |\n| costType |\n| date |\n| detailPageViews |\n| detailPageViewsClicks |\n| eCPAddToCart |\n| endDate |\n| impressions |\n| kindleEditionNormalizedPagesRead14d |\n| kindleEditionNormalizedPagesRoyalties14d |\n| newToBrandDetailPageViewRate |\n| newToBrandDetailPageViews |\n| newToBrandDetailPageViewsClicks |\n| newToBrandECPDetailPageView |\n| newToBrandPurchases |\n| newToBrandPurchasesClicks |\n| newToBrandPurchasesPercentage |\n| newToBrandPurchasesRate |\n| newToBrandSales |\n| newToBrandSalesClicks |\n| newToBrandSalesPercentage |\n| newToBrandUnitsSold |\n| newToBrandUnitsSoldClicks |\n| newToBrandUnitsSoldPercentage |\n| purchases |\n| purchasesClicks |\n| purchasesPromoted |\n| sales |\n| salesClicks |\n| salesPromoted |\n| startDate |\n| unitsSold |\n| unitsSoldClicks |\n| video5SecondViewRate |\n| video5SecondViews |\n| videoCompleteViews |\n| videoFirstQuartileViews |\n| videoMidpointViews |\n| videoThirdQuartileViews |\n| videoUnmutes |\n| viewabilityRate |\n| viewableImpressions |\n\n## Group by ads\n\n**Additional metrics**: N/A\n\n**Filters**:\n- adStatus (values: ENABLED, PAUSED, ARCHIVED)\n\n## Sample call\n\n```bash\ncurl --location 'https://advertising-api.amazon.com/reporting/reports' \\\n--header 'Content-Type: application/vnd.createasyncreportrequest.v3+json' \\\n--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxxxx' \\\n--header 'Amazon-Advertising-API-Scope: xxxxxxx' \\\n--header 'Authorization: Bearer Atza|xxxxxxxxxxx' \\\n--data '{\n    \"name\":\"SB advertised product report 9/5-9/10\",\n    \"startDate\":\"2023-09-05\",\n    \"endDate\":\"2023-09-10\",\n    \"configuration\":{\n        \"adProduct\":\"SPONSORED_BRANDS\",\n        \"groupBy\":[\"ads\"],\n        \"columns\":[\"impressions\",\"clicks\",\"cost\",\"campaignId\",\"adId\",\"adGroupId\"],\n        \"reportTypeId\":\"sbAds\",\n        \"timeUnit\":\"SUMMARY\",\n        \"format\":\"GZIP_JSON\"\n    }\n}'\n```\n\nFile v1.0.7:references/report-types/sb/sbCampaignPlacement.md\n\n---\nreportTypeId: sbCampaignPlacement\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/placement\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [campaign]\nformat: [GZIP_JSON]\nfilters: []\ndateRange:\n  maxSpanDays: 31\n  dataRetentionDays: 60\n---\n\n# SB Campaign Placement\n\nPlacement reports contain performance data broken down by ad placement.\n\n> **Note**\n> For Sponsored Products, there is not a separate placement report. You can get placement-level data using the 'campaignPlacement' groupBy in a campaign report.\n\n> **Note**\n> This report is currently available in preview. During the preview period, data related to Sponsored Brands campaigns with flag isMultiAdGroupsEnabled set to FALSE won't be available. Once version 3 reporting supports all Sponsored Brands campaigns, we will announce general availability in the release notes.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbCampaignPlacement |\n| Maximum date range | 31 days |\n| Data retention | 60 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | campaign |\n| format | GZIP_JSON |\n\n## Base metrics\n\n| Field |\n|------|\n| addToCart |\n| addToCartClicks |\n| addToCartRate |\n| addToList |\n| addToListFromClicks |\n| qualifiedBorrows |\n| qualifiedBorrowsFromClicks |\n| royaltyQualifiedBorrows |\n| royaltyQualifiedBorrowsFromClicks |\n| brandedSearches |\n| brandedSearchesClicks |\n| campaignBudgetAmount |\n| campaignBudgetCurrencyCode |\n| campaignBudgetType |\n| campaignId |\n| campaignName |\n| campaignStatus |\n| clicks |\n| cost |\n| costType |\n| date |\n| detailPageViews |\n| detailPageViewsClicks |\n| eCPAddToCart |\n| endDate |\n| impressions |\n| kindleEditionNormalizedPagesRead14d |\n| kindleEditionNormalizedPagesRoyalties14d |\n| newToBrandDetailPageViewRate |\n| newToBrandDetailPageViews |\n| newToBrandDetailPageViewsClicks |\n| newToBrandECPDetailPageView |\n| newToBrandPurchases |\n| newToBrandPurchasesClicks |\n| newToBrandPurchasesPercentage |\n| newToBrandPurchasesRate |\n| newToBrandSales |\n| newToBrandSalesClicks |\n| newToBrandSalesPercentage |\n| newToBrandUnitsSold |\n| newToBrandUnitsSoldClicks |\n| newToBrandUnitsSoldPercentage |\n| purchases |\n| purchasesClicks |\n| purchasesPromoted |\n| sales |\n| salesClicks |\n| salesPromoted |\n| startDate |\n| unitsSold |\n| unitsSoldClicks |\n| video5SecondViewRate |\n| video5SecondViews |\n| videoCompleteViews |\n| videoFirstQuartileViews |\n| videoMidpointViews |\n| videoThirdQuartileViews |\n| videoUnmutes |\n| viewabilityRate |\n| viewableImpressions |\n| viewClickThroughRate |\n\n## Group by campaignPlacement\n\n**Additional metrics**: placementClassification\n\n## Group by campaign\n\n**Additional metrics**: N/A\n\n## Sample call\n\n### Campaign placement summary report\n\n```bash\ncurl --location 'https://advertising-api.amazon.com/reporting/reports' \\\n--header 'Content-Type: application/vnd.createasyncreportrequest.v3+json' \\\n--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxxxx' \\\n--header 'Amazon-Advertising-API-Scope: xxxxxxx' \\\n--header 'Authorization: Bearer Atza|xxxxxxxx' \\\n--data '{\n    \"name\": \"SB placement report 9/5-9/10\",\n    \"startDate\": \"2023-09-05\",\n    \"endDate\": \"2023-09-10\",\n    \"configuration\": {\n        \"adProduct\": \"SPONSORED_BRANDS\",\n        \"groupBy\": [\n            \"campaignPlacement\"\n        ],\n        \"columns\": [\n            \"impressions\",\n            \"clicks\",\n            \"cost\",\n            \"campaignId\",\n            \"placementClassification\",\n            \"startDate\",\n            \"endDate\"\n        ],\n        \"reportTypeId\": \"sbCampaignPlacement\",\n        \"timeUnit\": \"SUMMARY\",\n        \"format\": \"GZIP_JSON\"\n    }\n}'\n```\n\nFile v1.0.7:references/report-types/sb/sbCampaigns.md\n\n---\nreportTypeId: sbCampaigns\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/campaign\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [campaign]\nformat: [GZIP_JSON]\nfilters:\n  - name: campaignStatus\n    values: [ENABLED, PAUSED, ARCHIVED]\n    applicableWhenGroupBy: [campaign]\ndateRange:\n  maxSpanDays: 31\n  dataRetentionDays: 60\n---\n\n# SB Campaigns\n\nCampaign reports contain performance data broken down at the campaign level. Campaign reports include all campaigns of the requested sponsored ad type that have performance activity for the requested days. For example, a Sponsored Products campaign report returns performance data for all Sponsored Products campaigns that received impressions on the chosen dates. Campaign reports can also be grouped by ad group and placement for more granular data.\n\n> **Note**\n> You can only use a filter that is supported by all groupBy values included in a report configuration. For campaign reports, this means that filters are only supported when you include a single groupBy value.\n\n> **Note**\n> This report currently available in preview. During the preview period, data related to Sponsored Brands campaigns with flag isMultiAdGroupsEnabled=False won't be available. Once version 3 reporting supports all Sponsored Brands campaigns, we will announce general availability in the release notes.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbCampaigns |\n| Maximum date range | 31 days |\n| Data retention | 60 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | campaign |\n| format | GZIP_JSON |\n\n## Base metrics\n\n| Field |\n|------|\n| addToCart |\n| addToCartClicks |\n| addToCartRate |\n| addToList |\n| addToListFromClicks |\n| qualifiedBorrows |\n| qualifiedBorrowsFromClicks |\n| royaltyQualifiedBorrows |\n| royaltyQualifiedBorrowsFromClicks |\n| brandedSearches |\n| brandedSearchesClicks |\n| campaignBudgetAmount |\n| campaignBudgetCurrencyCode |\n| campaignBudgetType |\n| campaignId |\n| campaignName |\n| campaignStatus |\n| clicks |\n| cost |\n| costType |\n| date |\n| detailPageViews |\n| detailPageViewsClicks |\n| eCPAddToCart |\n| endDate |\n| impressions |\n| kindleEditionNormalizedPagesRead14d |\n| kindleEditionNormalizedPagesRoyalties14d |\n| newToBrandDetailPageViewRate |\n| newToBrandDetailPageViews |\n| newToBrandDetailPageViewsClicks |\n| newToBrandECPDetailPageView |\n| brandStorePageView |\n| newToBrandPurchases |\n| newToBrandPurchasesClicks |\n| newToBrandPurchasesPercentage |\n| newToBrandPurchasesRate |\n| newToBrandSales |\n| newToBrandSalesClicks |\n| newToBrandSalesPercentage |\n| newToBrandUnitsSold |\n| newToBrandUnitsSoldClicks |\n| newToBrandUnitsSoldPercentage |\n| purchases |\n| purchasesClicks |\n| purchasesPromoted |\n| sales |\n| salesClicks |\n| salesPromoted |\n| startDate |\n| topOfSearchImpressionShare |\n| unitsSold |\n| unitsSoldClicks |\n| video5SecondViewRate |\n| video5SecondViews |\n| videoCompleteViews |\n| videoFirstQuartileViews |\n| videoMidpointViews |\n| videoThirdQuartileViews |\n| videoUnmutes |\n| viewabilityRate |\n| viewableImpressions |\n| viewClickThroughRate |\n\n## Group by campaign\n\n**Additional metrics**: campaignBudgetAmount, campaignBudgetCurrencyCode, campaignBudgetType, longTermSales, longTermROAS, topOfSearchImpressionShare\n\n**Filters**:\n- campaignStatus (values: ENABLED, PAUSED, ARCHIVED)\n\n## Sample calls\n\n### Campaign summary report grouped by campaign\n\n```bash\ncurl --location 'https://advertising-api.amazon.com/reporting/reports' \\\n--header 'Content-Type: application/vnd.createasyncreportrequest.v3+json' \\\n--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxx' \\\n--header 'Amazon-Advertising-API-Scope: xxxxxxxxx' \\\n--header 'Authorization: Bearer Atza|xxxxxxxxxx' \\\n--data '{\n    \"name\": \"SB campaigns report 9/5-9/10\",\n    \"startDate\": \"2023-09-05\",\n    \"endDate\": \"2023-09-10\",\n    \"configuration\": {\n        \"adProduct\": \"SPONSORED_BRANDS\",\n        \"groupBy\": [\n            \"campaign\"\n        ],\n        \"columns\": [\n            \"impressions\",\n            \"clicks\",\n            \"cost\",\n            \"campaignId\",\n            \"startDate\",\n            \"endDate\"\n        ],\n        \"reportTypeId\": \"sbCampaigns\",\n        \"timeUnit\": \"SUMMARY\",\n        \"format\": \"GZIP_JSON\"\n    }\n}'\n```\n\nFile v1.0.7:references/report-types/sb/sbGrossAndInvalids.md\n\n---\nreportTypeId: sbGrossAndInvalids\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/gross-and-invalid-traffic\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [campaign]\nformat: [GZIP_JSON, CSV]\nfilters:\n  - name: campaignStatus\n    values: [ENABLED, PAUSED, ARCHIVED]\n    applicableWhenGroupBy: [campaign]\ndateRange:\n  maxSpanDays: 365\n  dataRetentionDays: 365\n---\n\n# SB Gross and Invalid Traffic\n\nGross and invalid traffic report provides Sponsored Products, Sponsored Brands and Sponsored Display advertisers transparency into the nature of traffic on their campaigns. This report include all campaigns of the requested ad type and provides transparency on gross and invalid traffic metrics at campaign level for the requested days. For example, a Sponsored Products gross and invalid traffic report returns gross and invalid traffic metrics for all Sponsored Products campaigns that received impressions on the chosen dates.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbGrossAndInvalids |\n| Maximum date range | 365 days |\n| Data retention | 365 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | campaign |\n| format | GZIP_JSON or CSV |\n\n> Sponsored Products, Sponsored Brands, and Sponosred Display all support the same columns and configurations for the gross and invalid traffic report.\n\n## Base metrics\n\n| Field |\n|------|\n| campaignName |\n| campaignStatus |\n| clicks |\n| date |\n| endDate |\n| grossClickThroughs |\n| grossImpressions |\n| impressions |\n| invalidClickThroughRate |\n| invalidClickThroughs |\n| invalidImpressionRate |\n| invalidImpressions |\n| startDate |\n\n## Group by campaign\n\n**Additional metrics**: N/A\n\n**Filters**:\n- campaignStatus (values: ENABLED, PAUSED, ARCHIVED)\n\nFile v1.0.7:references/report-types/sb/sbPromptAdExtension.md\n\n---\nreportTypeId: sbPromptAdExtension\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/prompt-ad-extension\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [promptAdExtension]\nformat: [GZIP_JSON, XLSX]\nfilters:\n  - name: marketplaceId\n    values: [US]\n    applicableWhenGroupBy: [promptAdExtension]\ndateRange:\n  maxSpanDays: 90\n  dataRetentionDays: 95\n---\n\n# SB Prompt Ad Extension\n\nPrompt Ad Extension reports contain performance data for Sponsored Products and Sponsored Brands ads that include metrics for AI-powered prompt ads. Prompts are designed to help shoppers discover products through conversational experiences on Amazon by surfacing relevant product information through intelligent suggestions and guiding questions.\n\n## About Prompts\n\nPrompts are a new ad format that integrates into your existing Sponsored Products and Sponsored Brands campaigns with zero additional setup required. They enhance product discovery at crucial shopper decision points by:\n\n- Showcasing your product expertise at scale during critical shopper decision moments\n- Engaging high-intent shoppers with relevant product information\n- Anticipating and answering shopper questions about your products\n\nPrompts with clicks will show in your existing Sponsored Products or Sponsored Brands reporting, and you can pause individual prompts through the Amazon Ads console.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbPromptAdExtension |\n| Maximum date range | 90 days |\n| Data retention | 95 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | promptAdExtension |\n| format | GZIP_JSON or XLSX |\n\n## Base metrics\n\n| Field |\n|------|\n| date |\n| startDate |\n| endDate |\n| campaignId |\n| campaignName |\n| adGroupId |\n| adGroupName |\n| marketplaceId |\n| adId |\n| adName |\n| creativeExtensionId |\n| creativeExtensionType |\n| portfolioName |\n| campaignBudgetCurrencyCode |\n| promptText |\n| impressions |\n| clicks |\n| clickThroughRate |\n| costPerClick |\n| cost |\n| spend |\n| viewableImpressions |\n| acosClicks7d |\n| acosClicks14d |\n| roasClicks7d |\n| roasClicks14d |\n| purchases1d |\n| purchases7d |\n| purchases14d |\n| purchases30d |\n| purchasesSameSku1d |\n| purchasesSameSku7d |\n| purchasesSameSku14d |\n| purchasesSameSku30d |\n| purchasesOtherSku1d |\n| purchasesOtherSku7d |\n| purchasesOtherSku14d |\n| purchasesOtherSku30d |\n| unitsSoldClicks1d |\n| unitsSoldClicks7d |\n| unitsSoldClicks14d |\n| unitsSoldClicks30d |\n| unitsSoldSameSku1d |\n| unitsSoldSameSku7d |\n| unitsSoldSameSku14d |\n| unitsSoldSameSku30d |\n| unitsSoldOtherSku1d |\n| unitsSoldOtherSku7d |\n| unitsSoldOtherSku14d |\n| unitsSoldOtherSku30d |\n| sales1d |\n| sales7d |\n| sales14d |\n| sales30d |\n| attributedSalesSameSku1d |\n| attributedSalesSameSku7d |\n| attributedSalesSameSku14d |\n| attributedSalesSameSku30d |\n| salesOtherSku1d |\n| salesOtherSku7d |\n| salesOtherSku14d |\n| salesOtherSku30d |\n| purchaseClickRate7d |\n| purchaseClickRate14d |\n| newToBrandPurchases |\n| newToBrandPurchasesPercentage |\n| newToBrandUnitsSold |\n| newToBrandUnitsSoldPercentage |\n| newToBrandSales |\n| newToBrandSalesPercentage |\n\n## Group by promptAdExtension\n\n**Additional metrics**: N/A\n\n**Filters**:\n- marketplaceId (values: US)\n\n## Sample call\n\n```bash\ncurl --location 'https://advertising-api.amazon.com/reporting/reports' \\\n--header 'Content-Type: application/vnd.createasyncreportrequest.v3+json' \\\n--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxxxx' \\\n--header 'Amazon-Advertising-API-Scope: xxxxxxx' \\\n--header 'Authorization: Bearer Atza|xxxxxxxxxxx' \\\n--data '{\n    \"name\":\"SB prompt ad extension report 4/13-4/16\",\n    \"startDate\":\"2026-04-13\",\n    \"endDate\":\"2026-04-16\",\n    \"configuration\":{\n        \"adProduct\":\"SPONSORED_BRANDS\",\n        \"groupBy\":[\"promptAdExtension\"],\n        \"columns\":[\"date\",\"campaignId\",\"campaignName\",\"adGroupId\",\"adGroupName\",\"adId\",\"adName\",\"creativeExtensionId\",\"promptText\",\"impressions\",\"clicks\",\"cost\",\"purchases7d\",\"sales7d\",\"newToBrandPurchases\",\"newToBrandSales\"],\n        \"reportTypeId\":\"sbPromptAdExtension\",\n        \"timeUnit\":\"DAILY\",\n        \"format\":\"GZIP_JSON\"\n    }\n}'\n```\n\nArchive v1.0.6: 34 files, 72105 bytes\n\nFiles: references/api.md (10759b), references/onboarding.md (2046b), references/report-types/index.md (552b), references/report-types/sb/index.md (562b), references/report-types/sb/sbAdGroup.md (4001b), references/report-types/sb/sbAds.md (3314b), references/report-types/sb/sbCampaignPlacement.md (3673b), references/report-types/sb/sbCampaigns.md (4286b), references/report-types/sb/sbGrossAndInvalids.md (1786b), references/report-types/sb/sbPromptAdExtension.md (4170b), references/report-types/sb/sbPurchasedProduct.md (2262b), references/report-types/sb/sbSearchTerm.md (3788b), references/report-types/sb/sbTargeting.md (4330b), references/report-types/sd/index.md (426b), references/report-types/sd/sdAdGroup.md (3664b), references/report-types/sd/sdAdvertisedProduct.md (3473b), references/report-types/sd/sdCampaigns.md (3878b), references/report-types/sd/sdGrossAndInvalids.md (2544b), references/report-types/sd/sdPurchasedProduct.md (2742b), references/report-types/sd/sdTargeting.md (4672b), references/report-types/sp/index.md (494b), references/report-types/sp/spAdvertisedProduct.md (2794b), references/report-types/sp/spCampaigns.md (6362b), references/report-types/sp/spGrossAndInvalids.md (2747b), references/report-types/sp/spPromptAdExtension.md (3887b), references/report-types/sp/spPurchasedProduct.md (2869b), references/report-types/sp/spSearchTerm.md (4766b), references/report-types/sp/spTargeting.md (5365b), scripts/check_auth_dependency.py (6741b), scripts/get_report.py (32576b), scripts/onboarding.py (24089b), skill-card.md (2877b), SKILL.md (14301b), _meta.json (144b)\n\nFile v1.0.6:SKILL.md\n\n---\nname: linkfox-amazon-ads-report\ndescription: 亚马逊广告（Amazon Ads）报告一站式获取技能，覆盖 Sponsored Products (SP) / Sponsored Brands (SB) / Sponsored Display (SD) 全部报告类型。脚本自动完成报告的创建、等待、下载和解压，直接返回可读的结构化数据。真实可用的报告类型及每类的列清单/groupBy/filters 以 `references/report-types/<adProduct-dir>/<reportTypeId>.md` 为单一真相源。当用户提到拉取亚马逊广告报告、下载 Amazon Ads 报告、获取 SP/SB/SD 广告活动/关键词/搜索词/投放商品/购买商品/广告组/流量异常/Prompt 扩展等任意报告时触发。本技能依赖 linkfox-amazon-ads-auth。Sponsored Television (ST) / Amazon DSP 暂未覆盖。\n---\n\n# Amazon Ads 报告获取\n\n报告一站式获取：脚本经 `developerProxy` 传 `profileId`（服务端解析 token），自动完成报告的创建、等待（约 2–10 分钟）、下载和解压，直接返回可读的结构化数据。\n脚本本身不做\"该选哪些列 / 该怎么分组\"的业务判断，这些由 agent 先查 `references/report-types/` 下对应的 `.md` 文件，再显式传给脚本。\n\n**依赖 `linkfox-amazon-ads-auth`**（脚本启动自动检查；未安装时 exit 42，stderr 打 `DEPENDENCY_MISSING`）。\n\n### ⚠️ 多账号场景：调用前必须解析好 profileId\n\n用户经常只说自然语言（\"美国站\"、\"日本站\"、\"我的店铺\"），本 skill 的所有脚本都必须拿到数字 `profileId` 才能调。按下列顺序处理，**不要跳过**：\n\n1. 先调 `linkfox-amazon-ads-auth` 的 `authorized_stores.py` 拉出用户已授权的账号 × 站点清单。\n2. 根据用户提到的站点（映射到 `countryCode`，如 美国→`US`）匹配候选 profile：\n   - **只有 1 个候选** → 静默取对应 profileId，继续调用；不要把 profileId 数字播报给用户。\n   - **≥ 2 个候选（同站点下多个授权账号）** → **必须向用户澄清**，用 `accountName` 问：\"你在美国站授权了 A 和 B 两个账号，这次用哪个？\"\n   - **0 个候选** → 告知用户该站点未授权，引导去 `linkfox-amazon-ads-auth` 做授权。\n3. **严禁**让用户直接报 profileId 数字。\n4. **严禁**在歧义下\"挑第一个\"或\"选默认\"绕过澄清。\n\n完整决策表见 `linkfox-amazon-ads-auth` SKILL.md 的 **Usage Scenarios 第 4 节**。\n\n## 调用方式\n\n- **API 端点**：`POST /amazonAds/developerProxy`（不同操作通过请求体区分；完整参数/响应/错误码见 `references/api.md`）\n- **Python 脚本**：`python scripts/<脚本名>.py '<JSON 参数>' [--inline]`（可用脚本见上文脚本一览）\n- **成本约束**：本工具会消耗积分；失败/空结果不得自动换关键词、翻页或连续试探；需要继续检索时先向用户说明会产生额外消耗。\n\n**输出策略（脚本默认行为）**：\n- **始终**将完整响应写入 `<cwd>/linkfox/<YYYY-MM-DD>/<session>/data/<skill-name>-<timestamp>.json`（`<cwd>` 为脚本执行时的工作目录，在 Claude Code 里即当前项目目录；`<session>` 取自环境变量 `SESSION_ID`，按用户任务自动聚合；**禁止写入 /tmp**，当前目录不可写则报错）\n- 响应体 ≤ 8 KB：落盘后把完整 JSON 打印到 stdout\n- 响应体 > 8 KB：落盘后 stdout 只输出摘要（顶层字段、常见计数如 `total`/`costToken`、最大列表字段的长度 + 前 3 条样本）\n- 加 `--inline` 强制全量打印到 stdout（同样落盘）\n\n**读数据建议**：先看摘要判断是否足够；需要具体字段时优先用 `jq`或`ConvertFrom-Json`或`ConvertFrom-Json` 从保存的 json 文件按需抽取，避免整份 JSON 进入上下文。\n\n## 解决认证和积分问题\n发生以下异常情况时，采用 references/onboarding.md 引导解决问题：\n\n### 异常情况\n- **未配置API Key**：环境变量未配置 `LINKFOX_AGENT_API_KEY`，也未配置 `LINKFOXAGENT_API_KEY`。\n- **响应401或402状态码**\n- **响应提示积分或余额不足**：消息含\"积分余额不足/计费不足/余额不足/quota exceeded/insufficient balance/套餐到期/需充值/请充值\"，或类似含义的内容。\n\n## Core Concepts\n\n- **覆盖**：SP / SB / SD 全部报告类型（以 `references/report-types/` 下存在的 `.md` 为准；ST / DSP 暂未覆盖）\n- **一站式**：脚本内部自动完成报告创建 → 等待生成（约 2–10 分钟）→ 下载 → 解压，调用方只需等最终结果\n- **单脚本**：`get_report.py`（覆盖 SP / SB 全部 adProduct）\n- **元数据 vs. 运行参数**：\n  - 每个报告类型的**可用字段**（timeUnit / groupBy / filters / 全部列名）集中在 `references/report-types/<adProduct-dir>/<reportTypeId>.md`\n  - **脚本运行参数**（等待间隔、访问链接时效等）见本文件和 `references/api.md`\n\n## 可用脚本\n\n| 脚本 | 职责 |\n|------|------|\n| `get_report.py` ⭐ | 一站式执行。**必填** `adProduct` / `groupBy` / `columns`，由 agent 从 report-types/ 提取后传入 |\n| `check_auth_dependency.py` | 检测 linkfox-amazon-ads-auth 是否安装 |\n\n完整脚本参数、响应结构见 `references/api.md`。\n\n## Agent 调用流程\n\nAgent 触达\"拉取亚马逊广告报告\"类需求时，**必须**按下列顺序：\n\n1. **定 reportTypeId**：按用户意图挑选（如\"上周花费\"→ `spCampaigns`；\"哪个商品卖得好\"→ `spAdvertisedProduct` / `sbPurchasedProduct`；\"用户搜什么词找到我\"→ `spSearchTerm`）\n2. **查 reference**：打开 `references/report-types/<adProduct-dir>/<reportTypeId>.md`\n   - **frontmatter** 给出：`adProduct` / `groupBy`（Configuration 表推荐的） / `timeUnit`(可枚举) / `format` / `dateRange` / `filters`\n   - **Base metrics 表** 给出：此报告类型允许的全部列名\n3. **向用户咨询可定制条件**（用户答\"默认/随便\"时跳过，进入第 4 步的默认选择）：\n   - `timeUnit`：DAILY（按日拆分）还是 SUMMARY（汇总）\n   - `columns` 扩展：是否要归因列（sales7d / purchases7d / acosClicks7d / roasClicks7d）、视频指标、newToBrand 等\n   - `filters`：是否过滤 campaignStatus / keywordType / adStatus 等\n4. **按用户回复或默认构造 columns**（见下节 \"默认条件\"）\n5. **调脚本**：`adProduct` / `groupBy` / `columns` 三个必填字段**显式**传入\n\n## 默认条件（用户未指定时使用）\n\n| 条件 | 默认规则 |\n|------|---------|\n| `timeUnit` | 日期跨度 ≤ 7 天 → `DAILY`；> 7 天 → `SUMMARY` |\n| `columns` 身份维度 | `DAILY` 时必含 `date`；`SUMMARY` 时必含 `startDate` + `endDate`；再追加该报告的主键字段（参考 frontmatter 中 groupBy 对应的主键，如 campaignId+campaignName / advertisedAsin+advertisedSku / searchTerm / keyword 等） |\n| `columns` 基础指标 | `impressions` / `clicks` / `cost`（以该报告 Base metrics 存在的为准） |\n| `columns` 归因指标 | **仅当用户提到\"销售/转化/ROI/ACOS\"等意图时追加**：`sales7d` / `purchases7d` / `acosClicks7d` / `roasClicks7d`（以 Base metrics 存在者为准） |\n| `filters` | 不加（全量返回） |\n| `groupBy` | 取 frontmatter `groupBy` 数组的第一个值（即 Configuration 表里 Amazon 官方推荐的主维度） |\n\n## 请求示例\n\n所有 example 都显式传入三个必填字段（`adProduct` / `groupBy` / `columns`）。\n\n### 1. SP 广告活动报告（最常见）\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"adProduct\": \"SPONSORED_PRODUCTS\",\n  \"groupBy\": [\"campaign\"],\n  \"columns\": [\"date\",\"campaignId\",\"campaignName\",\"impressions\",\"clicks\",\"cost\"],\n  \"startDate\": \"2026-04-27\",\"endDate\": \"2026-05-03\",\n  \"timeUnit\": \"DAILY\"\n}'\n```\n\n### 2. SP 搜索词报告（含归因）\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"spSearchTerm\",\n  \"adProduct\": \"SPONSORED_PRODUCTS\",\n  \"groupBy\": [\"searchTerm\"],\n  \"columns\": [\"searchTerm\",\"keyword\",\"matchType\",\"impressions\",\"clicks\",\"cost\",\n              \"sales7d\",\"sales14d\",\"purchases7d\",\"acosClicks14d\",\"roasClicks14d\",\n              \"startDate\",\"endDate\"],\n  \"startDate\": \"2026-04-01\",\"endDate\": \"2026-04-30\",\n  \"timeUnit\": \"SUMMARY\",\n  \"filters\": [{\"field\":\"keywordType\",\"values\":[\"BROAD\",\"PHRASE\",\"EXACT\"]}]\n}'\n```\n\n### 3. SB 广告组报告\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"sbAdGroup\",\n  \"adProduct\": \"SPONSORED_BRANDS\",\n  \"groupBy\": [\"adGroup\"],\n  \"columns\": [\"adGroupId\",\"adGroupName\",\"impressions\",\"clicks\",\"cost\",\"purchases\",\"sales\",\"startDate\",\"endDate\"],\n  \"startDate\": \"2026-04-01\",\"endDate\": \"2026-04-30\"\n}'\n```\n\n### 4. SD 广告活动报告\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"sdCampaigns\",\n  \"adProduct\": \"SPONSORED_DISPLAY\",\n  \"groupBy\": [\"campaign\"],\n  \"columns\": [\"date\",\"campaignId\",\"campaignName\",\"impressions\",\"clicks\",\"cost\",\"purchases\",\"sales\"],\n  \"startDate\": \"2026-04-27\",\"endDate\": \"2026-05-03\",\n  \"timeUnit\": \"DAILY\"\n}'\n```\n\n### 5. 轮询一个已有 reportId（救回上次超时 / 手工恢复）\n\n当上次运行因为客户端轮询窗口太短退出、但报告在 Amazon 侧仍在跑时，直接传入 `reportId` 即可跳过创建，继续轮询并下载。此模式下只需 `profileId` / `region` / `reportId`，其余字段不必填。\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportId\": \"7df1ef5d-45ba-40cc-b607-ff2148cf4f5e\",\n  \"maxAttempts\": 60, \"pollInterval\": 30\n}'\n```\n\n> **自动恢复**：如果调用方未传 `reportId`、且 Amazon 对同参数请求触发去重（返回 HTTP 425 `The Request is a duplicate of : <uuid>`），脚本会自动解析出老 reportId 并转为轮询该老报告，无需重试。\n\n## 响应格式\n\n成功：\n```json\n{\n  \"success\": true,\n  \"reportId\": \"4ee811a0-...\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"startDate\": \"2026-04-28\", \"endDate\": \"2026-05-04\",\n  \"downloadPath\": \"C:/.../tmp/report_data.json\",\n  \"extractedFileHttpUrl\": \"http://127.0.0.1:51234/download\",\n  \"extractedFileHttpServeSeconds\": 300\n}\n```\n\n失败：\n```json\n{\"error\":\"Upstream HTTP 400\",\"httpStatus\":400,\n \"body\":\"{\\\"code\\\":\\\"400\\\",\\\"detail\\\":\\\"startDate to endDate range (32 days) must not exceed maximum range (31 days)\\\"}\"}\n```\n\n## 调用原则\n\n- 用户指定了 reportTypeId 就只拉那一种，不擅自替换\n- 报告失败（非 2xx 或 status=FAILED）时如实告知错误原因，不盲目重试\n- 成功后把报告的本地文件路径和访问链接完整展示给用户，并提醒访问链接有时效（默认 5 分钟内有效，过期需重新拉取）\n- **超时不是失败**：当脚本返回 `status=STILL_PROCESSING`（exit code=2），说明客户端已等满默认 10 分钟但报告仍在 Amazon 侧生成。此时 **必须**向用户说明情况并询问是否继续等待，绝不能当成失败处理。参考回复：\"报告还在 Amazon 侧生成中（已等 10 分钟），要继续等吗？可以选：A. 再等 ~20 分钟（maxAttempts=60）、B. 再等 ~1 小时（maxAttempts=120）、C. 先停，我稍后用 reportId 回来。\" 用户选 A/B → 用 `resumeHint.params` 切到仅轮询模式续跑\n\n## 常见错误\n\n| 状态 | 含义 | 建议 |\n|------|------|------|\n| `Missing required parameters: adProduct/groupBy/columns` | 调用方未显式传入三必填 | 回到 \"Agent 调用流程\" 第 2 步，从 `references/report-types/<adProduct-dir>/<reportTypeId>.md` 读出并补上 |\n| `HTTP 401` | accessToken 过期 | 调 ads-auth 的 `refresh_token.py` 后重试 |\n| `HTTP 403` | 未关联广告账户或权限不足 | 到 Amazon Ads 后台检查经理账户/广告账户关联 |\n| `HTTP 400 \"must not exceed maximum range\"` | 日期跨度超限（多数 31 天） | 拆分拉取后本地合并；具体上限看对应 `.md` frontmatter `dateRange.maxSpanDays` |\n| `HTTP 400` 含 `columns`/`groupBy` 校验错 | 列名拼写错 / 与 reportTypeId 不匹配 / 超出 Base metrics | 对照 `.md` 文件 Base metrics 表核对 |\n| `status=FAILED` 含 `failureReason` | 上游生成失败 | 多为日期窗口或权限问题，按 failureReason 具体处理 |\n| `status=STILL_PROCESSING` (exit 2) | 客户端轮询窗口耗尽但报告仍在生成 | **不是失败**。stdout 已含 `reportId` 与 `resumeHint.params`。询问用户是否继续等，用该 params（带 `reportId` + 更大 `maxAttempts`）切到仅轮询模式续跑 |\n| `HTTP 425 \"duplicate of\"` | 同参数已有在跑的报告 | 脚本自动解析并转为轮询该老 reportId，正常情况下调用方无需干预 |\n| exit 42 | 依赖 skill 未安装 | 先装 `linkfox-amazon-ads-auth` |\n\n## 日期与数据\n\n- **日期跨度上限**：多数报告 31 天；`sbPurchasedProduct` 是 731 天；`spGrossAndInvalids` / `sbGrossAndInvalids` / `sdGrossAndInvalids` 是 365 天（以 frontmatter 为准）\n- **回溯窗口**：SP 默认 95 天、SB 60 天、GrossAndInvalids 365 天；具体以 frontmatter `dateRange.dataRetentionDays` 为准\n- **数据延迟约 12 小时**；`endDate >= 今天` 脚本 stderr 警告但不拦截\n- **空数据不等于报错**：账号当期无投放时报告会成功生成，JSON 可能为 `[]` 或指标全 0\n\n## Not Applicable\n\n- Brand Analytics / Retail Analytics / Attribution 报告 → 不在本 skill\n- 报告删除 / 修改 / 定时任务 → 不在本 skill\n- 实体元数据（campaign 名、keyword 匹配类型等）→ `linkfox-amazon-ads-manager`\n- 授权 / token → `linkfox-amazon-ads-auth`\n\n## 积分消耗规则\n\n不消耗积分。\n\n**Feedback:**\n\nAuto-detect and report feedback via the Feedback API when any of the following apply:\n1. The functionality or purpose described in this skill does not match actual behavior\n2. The skill's results do not match the user's intent\n3. The user expresses dissatisfaction or praise about this skill\n4. Anything you believe could be improved\n\nCall the feedback API as specified in `references/api.md`. Do not interrupt the user's flow.\n\n---\n*For more high-quality, professional cross-border e-commerce skills, visit [LinkFox Skills](https://skill.linkfox.com/).*\n\nFile v1.0.6:_meta.json\n\n{\n  \"ownerId\": \"kn7dmc1t4j28hem1twwyav85p182pb1j\",\n  \"slug\": \"linkfox-amazon-ads-report\",\n  \"version\": \"1.0.6\",\n  \"publishedAt\": 1786099149974\n}\n\nFile v1.0.6:references/api.md\n\n# linkfox-amazon-ads-report — 参数与字段参考\n\nAmazon Ads 报告自动化获取（SP / SB 覆盖；SD / ST / DSP 暂未覆盖）。授权见 `linkfox-amazon-ads-auth`；广告管理见 `linkfox-amazon-ads-manager`。\n\n> **📌 报告类型的真相源**：每个 `reportTypeId` 的完整规格（可用 columns / groupBy / filters / timeUnit / 日期约束 / 官方示例）在 `references/report-types/<adProduct-dir>/<reportTypeId>.md`，**按 adProduct 分目录**：\n> - `report-types/sp/`（Sponsored Products）\n> - `report-types/sb/`（Sponsored Brands）\n>\n> 目录总览见 `report-types/index.md`。本文件仅给运行时脚本参数与通用规则。\n\n## 支持的报告类型\n\n完整列表见 `report-types/index.md` 及各 adProduct 子目录下的 `index.md`。常用快速索引：\n\n| reportTypeId | 业务含义 | 文件 |\n|--------------|---------|------|\n| `spCampaigns` | 广告活动级（SP） | `report-types/sp/spCampaigns.md` |\n| `spAdvertisedProduct` | 投放商品级（SP） | `report-types/sp/spAdvertisedProduct.md` |\n| `spSearchTerm` | 搜索词级（SP） | `report-types/sp/spSearchTerm.md` |\n| `spTargeting` | 定向/关键词级（SP） | `report-types/sp/spTargeting.md` |\n| `sbCampaigns` / `sbAdGroup` / `sbAds` / ... | Sponsored Brands | `report-types/sb/*.md` |\n\n## 输入参数\n\n脚本支持两种模式：\n\n- **全链路模式（默认）**：创建报告 → 轮询 → 下载。需要下表全部必填字段。\n- **仅轮询模式**：入参中显式传入 `reportId`（见下方\"可选流程参数\"），跳过创建，只需 `profileId` / `region`，其余全部可省略。用于救回上次客户端超时但报告仍在跑的场景。\n\n### 必填（全链路模式）\n\n| 参数 | 类型 | 说明 |\n|------|------|------|\n| `profileId` | number | 从 ads-auth 获取 |\n| `region` | string | `NA` / `EU` / `FE` |\n| `reportTypeId` | string | 见 `report-types/index.md` 各 adProduct 子目录下的完整列表 |\n| `adProduct` | string | 取自对应 `.md` 文件的 frontmatter（`SPONSORED_PRODUCTS` / `SPONSORED_BRANDS`）|\n| `groupBy` | list | 取自对应 `.md` 文件的 frontmatter |\n| `columns` | list | 取自对应 `.md` 文件 Base metrics 表的子集 |\n| `startDate` | string | `YYYY-MM-DD`（含当天） |\n| `endDate` | string | `YYYY-MM-DD`（含当天） |\n\n### 可选业务参数\n\n| 参数 | 默认 | 说明 |\n|------|------|------|\n| `name` | `{reportTypeId}_{startDate}_{endDate}` | 报告显示名 |\n| `timeUnit` | `SUMMARY` | `DAILY`（每天一行） / `SUMMARY`（整期一行） |\n| `format` | `GZIP_JSON` | 响应文件格式 |\n| `filters` | 空 | 过滤条件数组，字段与取值见对应 `.md` 文件 |\n\n### 可选流程参数\n\n| 参数 | 默认 | 说明 |\n|------|------|------|\n| `reportId` | 无 | 若显式传入，脚本进入**仅轮询模式**：跳过创建步骤，直接对该 reportId 轮询与下载。此时只要 `profileId` / `region` + `reportId`，其他字段可省 |\n| `pollInterval` | 30 | 轮询间隔秒 |\n| `maxAttempts` | 20 | 最大轮询次数（默认 10 分钟上限） |\n| `skipDepCheck` | false | 跳过依赖检查 |\n| `serveExtractedFileHttp` | true | 是否启本机 HTTP 服务 |\n| `serveHost` | `127.0.0.1` | 绑定地址（仅本机可访问） |\n| `servePort` | 0 | 端口（0=系统分配） |\n| `serveSeconds` | 300 | HTTP 服务存活秒 |\n| `includeAmazonSourceUrl` | false | 响应中带预签名 URL |\n\n## 日期限制\n\n- **跨度上限**：以对应 `.md` 文件 frontmatter 的 `dateRange.maxSpanDays` 为准（多数 31 天；`sbPurchasedProduct` 731 天；GrossAndInvalids 系列 365 天）。超出返回 HTTP 400 `\"must not exceed maximum range\"`。\n- **回溯上限**：以 `dateRange.dataRetentionDays` 为准（SP 多为 95 天，SB 60 天）。\n- **数据延迟**：~12 小时；`endDate >= 今天` 脚本会 stderr 警告但不拦截。建议 `endDate <= 昨天`。\n\n## 各报告类型的列\n\n每个 reportTypeId 的完整 Base metrics 列表、allowed groupBy、filters 枚举值，统一在 `report-types/<adProduct-dir>/<reportTypeId>.md` 中维护：\n\n- `.md` 的 **frontmatter** 提供 `adProduct` / `groupBy` / `timeUnit`（可选值）/ `format` / `filters` / `dateRange`\n- **Base metrics 表**列出此报告类型支持的**全部列名**；调用方按业务需要选子集\n\n归因窗口后缀约定：`_1d` / `_7d` / `_14d` / `_30d` 表示 1/7/14/30 天归因窗口（点击或曝光归因的销售额、订单量、件数等）。具体每个字段支持哪些窗口，以对应 `.md` 文件的 Base metrics 表为准（不是所有字段都有全部 4 个窗口版本）。\n\n## 工作流与输出\n\n脚本流程：依赖检查 → 取 token → 创建报告 → 等待生成（每 `pollInterval` 秒查询一次状态）→ 下载 GZIP_JSON（Amazon 预签名 URL 约 1 小时有效）→ 解压为可读 JSON → 通过本机 `127.0.0.1` 上的临时 HTTP 服务对调用方暴露（`serveSeconds` 后自动关闭）→ 输出调用结果 JSON（含本地文件路径与访问链接）。\n\n`status` 枚举：`PENDING` / `PROCESSING` / `COMPLETED` / `FAILED`。\n\n### 成功响应\n\n```json\n{\n  \"success\": true,\n  \"reportId\": \"4ee811a0-6aaa-4ceb-9d31-d3bcecf85430\",\n  \"status\": \"COMPLETED\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"startDate\": \"2026-04-28\", \"endDate\": \"2026-05-04\",\n  \"pollAttempts\": 13, \"elapsedSeconds\": 255,\n  \"downloadPath\": \"C:/.../tmp/report-xxx.json\",\n  \"extractedFileHttpUrl\": \"http://127.0.0.1:51234/report-xxx.json\",\n  \"serveExpiresAt\": \"2026-05-06T14:54:03+08:00\"\n}\n```\n\n### 失败响应\n\n**a) 创建阶段非 2xx**：\n```json\n{\"error\":\"Upstream HTTP 400\",\"httpStatus\":400,\n \"body\":\"{\\\"code\\\":\\\"400\\\",\\\"detail\\\":\\\"startDate to endDate range (32 days) must not exceed maximum range (31 days)\\\"}\"}\n```\n\n**b) 报告生成失败**（`failureReason` 从上游透传）：\n```json\n{\"success\":false,\"error\":\"Report generation failed with status=FAILED\",\n \"reportId\":\"4ee811a0-...\",\"status\":\"FAILED\",\n \"failureReason\":\"Requested columns are not supported for this report type.\",\n \"pollAttempts\":3}\n```\n\n**c) 轮询超时**（报告未坏，仅客户端等待窗口耗尽 — **exit code = 2**）：\n```json\n{\n  \"success\": false,\n  \"status\": \"STILL_PROCESSING\",\n  \"reportId\": \"4ee811a0-...\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"profileId\": 1234567890,\n  \"lastStatus\": \"PROCESSING\",\n  \"pollAttempts\": 20,\n  \"elapsedSeconds\": 600,\n  \"message\": \"客户端已等 ~600 秒（20 次轮询）报告仍在 Amazon 侧生成，并未失败。用 reportId 切换到仅轮询模式即可继续等待。\",\n  \"resumeHint\": {\n    \"mode\": \"poll-only\",\n    \"note\": \"传入 reportId + 更大的 maxAttempts 继续轮询同一份报告\",\n    \"params\": {\"profileId\": 1234567890, \"region\": \"NA\", \"reportId\": \"4ee811a0-...\", \"maxAttempts\": 60, \"pollInterval\": 30}\n  }\n}\n```\n\n调用方收到此响应应视为\"未完成\"而非\"失败\"，询问用户是否继续等待，直接把 `resumeHint.params` 作为入参续调 `get_report.py`。\n\n## 错误码\n\n| httpStatus / exit | 含义 | 建议 |\n|-------------------|------|------|\n| 200 | 成功 | 消费 `extractedFileHttpUrl` 或 `downloadPath` |\n| 400 | 入参错（日期超限 / reportTypeId 非法 / columns 不适配） | 按 `detail` 修正 |\n| 401 | accessToken 过期 | HTTP 401 或 authorized error：按 SKILL.md 的 **## 解决认证和积分问题** 处理。 |\n| 402 | 积分或余额不足 | HTTP 402：按 SKILL.md 的 **## 解决认证和积分问题** 处理。 |\n| 403 | profileId 无权限 | 核对 profileId |\n| 404 | reportId 不存在或已过期 | 重新发起报告 |\n| 422 | columns / groupBy 与 reportTypeId 不适配 | 对照 `report-types/<adProduct-dir>/<reportTypeId>.md` 的 Base metrics / frontmatter 核对 |\n| 425 | 同参数已有在跑的报告，Amazon 做了去重；body 形如 `\"The Request is a duplicate of : <reportId>\"` | **脚本自动解析该 reportId 并无缝转为轮询该老报告**，正常情况下无需干预；若调用方自行处理，也可把 reportId 拿出来，下次改用仅轮询模式（`{..., \"reportId\":\"<uuid>\"}`） |\n| 429 | 限流（~30 req/min/profile） | 间隔 30s 重试 |\n| `status=FAILED` | 上游生成失败 | 看 `failureReason` |\n| `status=STILL_PROCESSING` (exit 2) | 客户端轮询窗口耗尽但报告仍在 Amazon 侧生成 | **非失败**。stdout 已输出 `reportId` 与 `resumeHint.params`。询问用户是否继续等，用 params 切到仅轮询模式续跑（maxAttempts=60 约 30 分钟 / =120 约 1 小时） |\n| exit 42 | 依赖 skill 未安装 | 先装 `linkfox-amazon-ads-auth` |\n\n## 调用示例\n\n```bash\n# 1. SP 广告活动汇总（DAILY，一周）\npython get_report.py '{\"profileId\":1111111111,\"region\":\"NA\",\n  \"reportTypeId\":\"spCampaigns\",\n  \"adProduct\":\"SPONSORED_PRODUCTS\",\n  \"groupBy\":[\"campaign\"],\n  \"columns\":[\"date\",\"campaignId\",\"campaignName\",\"impressions\",\"clicks\",\"cost\"],\n  \"startDate\":\"2026-04-27\",\"endDate\":\"2026-05-03\",\n  \"timeUnit\":\"DAILY\"}'\n\n# 2. SP 搜索词 + 多归因窗口 + 过滤仅看关键词匹配\npython get_report.py '{\"profileId\":1111111111,\"region\":\"NA\",\n  \"reportTypeId\":\"spSearchTerm\",\n  \"adProduct\":\"SPONSORED_PRODUCTS\",\n  \"groupBy\":[\"searchTerm\"],\n  \"columns\":[\"searchTerm\",\"keyword\",\"matchType\",\"impressions\",\"clicks\",\"cost\",\n             \"sales7d\",\"sales14d\",\"sales30d\",\n             \"purchases7d\",\"purchases14d\",\"purchases30d\",\n             \"acosClicks14d\",\"roasClicks14d\",\"startDate\",\"endDate\"],\n  \"startDate\":\"2026-04-01\",\"endDate\":\"2026-04-30\",\n  \"timeUnit\":\"SUMMARY\",\n  \"filters\":[{\"field\":\"keywordType\",\"values\":[\"BROAD\",\"PHRASE\",\"EXACT\"]}]}'\n\n# 3. SP 投放商品 + 长时间等待 + 不启本机 HTTP\npython get_report.py '{\"profileId\":1111111111,\"region\":\"NA\",\n  \"reportTypeId\":\"spAdvertisedProduct\",\n  \"adProduct\":\"SPONSORED_PRODUCTS\",\n  \"groupBy\":[\"advertiser\"],\n  \"columns\":[\"advertisedAsin\",\"advertisedSku\",\"impressions\",\"clicks\",\"cost\",\n             \"sales7d\",\"acosClicks7d\",\"roasClicks7d\",\"startDate\",\"endDate\"],\n  \"startDate\":\"2026-04-01\",\"endDate\":\"2026-04-30\",\n  \"timeUnit\":\"SUMMARY\",\n  \"maxAttempts\":60,\"pollInterval\":20,\"serveExtractedFileHttp\":false}'\n\n# 4. 仅轮询一个已有 reportId（救回上次超时）\npython get_report.py '{\"profileId\":1111111111,\"region\":\"NA\",\n  \"reportId\":\"7df1ef5d-45ba-40cc-b607-ff2148cf4f5e\",\n  \"maxAttempts\":60,\"pollInterval\":30}'\n```\n\n---\n\n## Feedback API\n\n与上面的工具 API **base URL 不同**：\n\n```bash\ncurl -X POST https://skill-api.linkfox.com/api/v1/public/feedback \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"skillName\":\"linkfox-amazon-ads-report\",\"sentiment\":\"POSITIVE\",\n       \"category\":\"OTHER\",\"content\":\"报告拉取顺利\"}'\n```\n\n- `sentiment`: `POSITIVE` / `NEUTRAL` / `NEGATIVE`\n- `category`: `BUG` / `COMPLAINT` / `SUGGESTION` / `OTHER`\n\nFile v1.0.6:references/onboarding.md\n\n# 解决认证和积分问题\n\n调用本 skill 时若网关返回 **auth** 或 **billing** 错误，走本 skill 自带的 `scripts/onboarding.py` 完成引导。\n\n**auth 场景**：`errcode=401` 或消息含 `authorized error`/`鉴权失败`/`未授权`/`unauthorized`；或 `LINKFOX_AGENT_API_KEY` 与 `LINKFOXAGENT_API_KEY` 均为空。\n1. 若已配置 key → 先让用户重启会话（最常见误判），仍失败让用户重新取 key 或换手机号重注册\n2. 未配置 → 询问：自助去 https://agent.linkfox.com/ 取 key，或提供手机号让脚本注册\n3. 手机号路径：\n   - `python scripts/onboarding.py send-code <phone>` → 展示 JSON 里的 phone/agreements\n   - 收到验证码后：`python scripts/onboarding.py login <phone> <code>`（workbuddy 宿主加 `--channel workbuddy`）\n   - 拿到 `api_key` 后把下面三平台配置转发给用户，提示重启会话生效：\n     - Windows PowerShell（永久）：`setx LINKFOX_AGENT_API_KEY \"<key>\"`\n     - macOS zsh：`echo 'export LINKFOX_AGENT_API_KEY=\"<key>\"' >> ~/.zshrc && source ~/.zshrc`\n     - Linux bash：`echo 'export LINKFOX_AGENT_API_KEY=\"<key>\"' >> ~/.bashrc && source ~/.bashrc`\n     - 变量名 `LINKFOX_AGENT_API_KEY`（主推）或 `LINKFOXAGENT_API_KEY`（老规范）任一即可\n\n**billing 场景**：`errcode=402` 或消息含 `积分/余额/quota/insufficient/充值/套餐到期`。\n- `python scripts/onboarding.py list-plans` → 有 AskUserQuestion 就弹菜单，否则输出编号清单让用户选\n- 校验 `plan_id` ∈ 清单、支付方式 ∈ 该套餐 `available_methods`（通常 `wechat/alipay`）\n- `python scripts/onboarding.py order <plan_id> <method>` → 展示优先级 PNG > `pay_url` > `ascii_qr`（标注兜底）\n- 已付款可选调 `python scripts/onboarding.py query <order_id>`，不主动轮询\n\n排除 `errcode=403`（无权限，不归入这两类）。所有子命令输出 stdout JSON，`error` 字段已含阶段前缀，透传给用户即可。完整用法：`python scripts/onboarding.py --help`。\n\nFile v1.0.6:references/report-types/index.md\n\n# Amazon Ads Report Types\n\n按 `adProduct` 分类。每个 `.md` 文件名即 `reportTypeId`，内容为官方原文 + YAML frontmatter 结构化字段，用于构造 `POST /reporting/reports` 请求体。\n\n## 目录\n\n| adProduct | 目录 |\n|-----------|------|\n| SPONSORED_PRODUCTS | [`sp/`](./sp/) |\n| SPONSORED_BRANDS | [`sb/`](./sb/) |\n| SPONSORED_DISPLAY | [`sd/`](./sd/) |\n\n> Sponsored Television (ST) / Amazon DSP 暂未覆盖，后续版本支持。\n\n## 数据源\n\nhttps://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types\n\nFile v1.0.6:references/report-types/sb/index.md\n\n# Sponsored Brands (SB) Report Types\n\n`adProduct = SPONSORED_BRANDS`\n\n| reportTypeId | 状态 |\n|--------------|------|\n| [`sbAdGroup`](./sbAdGroup.md) | ✅ |\n| [`sbAds`](./sbAds.md) | ✅ |\n| [`sbCampaigns`](./sbCampaigns.md) | ✅ |\n| [`sbCampaignPlacement`](./sbCampaignPlacement.md) | ✅ |\n| [`sbGrossAndInvalids`](./sbGrossAndInvalids.md) | ✅ |\n| [`sbPromptAdExtension`](./sbPromptAdExtension.md) | ✅ |\n| [`sbPurchasedProduct`](./sbPurchasedProduct.md) | ✅ |\n| [`sbSearchTerm`](./sbSearchTerm.md) | ✅ |\n| [`sbTargeting`](./sbTargeting.md) | ✅ |\n\nFile v1.0.6:references/report-types/sb/sbAdGroup.md\n\n---\nreportTypeId: sbAdGroup\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/ad-group\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [adGroup]\nformat: [GZIP_JSON]\nfilters:\n  - name: adStatus\n    values: [ENABLED, PAUSED, ARCHIVED]\n    applicableWhenGroupBy: [adGroup]\ndateRange:\n  maxSpanDays: 31\n  dataRetentionDays: 60\n---\n\n# SB Ad Group\n\nAd group reports contain performance data broken down at the ad group level. Ad group reports include all campaigns of the requested sponsored ad type that have performance activity for the requested days. For example, a Sponsored Brands ad group report returns performance data for all Sponsored Brands ad groups that received impressions on the chosen dates.\n\n> **Note**\n> For Sponsored Products, there is not a separate ad group report. You can get ad group-level data using the ad group groupBy in a campaign report.\n\n> **Note**\n> This report currently available in preview. During the preview period, data related to Sponsored Brands campaigns with flag isMultiAdGroupsEnabled=False won't be available. Once version 3 reporting supports all Sponsored Brands campaigns, we will announce general availability in the release notes.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbAdGroup |\n| Maximum date range | 31 days |\n| Data retention | 60 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | adGroup |\n| format | GZIP_JSON |\n\n## Base metrics\n\n| Field |\n|------|\n| addToCart |\n| addToCartClicks |\n| addToCartRate |\n| adGroupId |\n| adGroupName |\n| adStatus |\n| addToList |\n| addToListFromClicks |\n| qualifiedBorrows |\n| qualifiedBorrowsFromClicks |\n| royaltyQualifiedBorrows |\n| royaltyQualifiedBorrowsFromClicks |\n| brandedSearches |\n| brandedSearchesClicks |\n| campaignBudgetAmount |\n| campaignBudgetCurrencyCode |\n| campaignBudgetType |\n| campaignId |\n| campaignName |\n| campaignStatus |\n| clicks |\n| cost |\n| costType |\n| date |\n| detailPageViews |\n| detailPageViewsClicks |\n| eCPAddToCart |\n| endDate |\n| impressions |\n| kindleEditionNormalizedPagesRead14d |\n| kindleEditionNormalizedPagesRoyalties14d |\n| newToBrandDetailPageViewRate |\n| newToBrandDetailPageViews |\n| newToBrandDetailPageViewsClicks |\n| newToBrandECPDetailPageView |\n| newToBrandPurchases |\n| newToBrandPurchasesClicks |\n| newToBrandPurchasesPercentage |\n| newToBrandPurchasesRate |\n| newToBrandSales |\n| newToBrandSalesClicks |\n| newToBrandSalesPercentage |\n| newToBrandUnitsSold |\n| newToBrandUnitsSoldClicks |\n| newToBrandUnitsSoldPercentage |\n| purchases |\n| purchasesClicks |\n| purchasesPromoted |\n| sales |\n| salesClicks |\n| salesPromoted |\n| startDate |\n| unitsSold |\n| unitsSoldClicks |\n| video5SecondViewRate |\n| video5SecondViews |\n| videoCompleteViews |\n| videoFirstQuartileViews |\n| videoMidpointViews |\n| videoThirdQuartileViews |\n| videoUnmutes |\n| viewabilityRate |\n\n## Group by adGroup\n\n**Additional metrics**: N/A\n\n**Filters**:\n- adStatus (values: ENABLED, PAUSED, ARCHIVED)\n\n## Group by campaign\n\n**Additional metrics**: N/A\n\n## Sample call\n\n### Ad group summary report grouped by ad group\n\n```bash\ncurl --location 'https://advertising-api.amazon.com/reporting/reports' \\\n--header 'Content-Type: application/vnd.createasyncreportrequest.v3+json' \\\n--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxx' \\\n--header 'Amazon-Advertising-API-Scope: xxxxxxxx' \\\n--header 'Authorization: Bearer Atza|xxxxxxxxxxx' \\\n--data '{\n    \"name\": \"SB ad group report 9/5-9/10\",\n    \"startDate\": \"2023-09-05\",\n    \"endDate\": \"2023-09-10\",\n    \"configuration\": {\n        \"adProduct\": \"SPONSORED_BRANDS\",\n        \"groupBy\": [\n            \"adGroup\"\n        ],\n        \"columns\": [\n            \"impressions\",\n            \"clicks\",\n            \"cost\",\n            \"campaignId\",\n            \"adGroupId\",\n            \"startDate\",\n            \"endDate\"\n        ],\n        \"reportTypeId\": \"sbAdGroup\",\n        \"timeUnit\": \"SUMMARY\",\n        \"format\": \"GZIP_JSON\"\n    }\n}'\n```\n\nFile v1.0.6:references/report-types/sb/sbAds.md\n\n---\nreportTypeId: sbAds\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/ad\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [ads]\nformat: [GZIP_JSON]\nfilters:\n  - name: adStatus\n    values: [ENABLED, PAUSED, ARCHIVED]\n    applicableWhenGroupBy: [ads]\ndateRange:\n  maxSpanDays: 31\n  dataRetentionDays: 60\n---\n\n# SB Ads\n\nAdvertised product reports contain performance data for campaigns at the ad level.\n\n> **Note**\n> This report is currently available in preview. During the preview period, data related to Sponsored Brands campaigns with flag isMultiAdGroupsEnabled set to FALSE won't be available. Once version 3 reporting supports all Sponsored Brands campaigns, we will announce general availability in the release notes.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbAds |\n| Maximum date range | 31 days |\n| Data retention | 60 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | ads |\n| format | GZIP_JSON |\n\n## Base metrics\n\n| Field |\n|------|\n| addToCart |\n| addToCartClicks |\n| addToCartRate |\n| addToList |\n| qualifiedBorrows |\n| royaltyQualifiedBorrows |\n| addToListFromClicks |\n| qualifiedBorrowsFromClicks |\n| royaltyQualifiedBorrowsFromClicks |\n| adGroupId |\n| adGroupName |\n| adId |\n| brandedSearches |\n| brandedSearchesClicks |\n| campaignBudgetAmount |\n| campaignBudgetCurrencyCode |\n| campaignBudgetType |\n| campaignId |\n| campaignName |\n| campaignStatus |\n| clicks |\n| cost |\n| costType |\n| date |\n| detailPageViews |\n| detailPageViewsClicks |\n| eCPAddToCart |\n| endDate |\n| impressions |\n| kindleEditionNormalizedPagesRead14d |\n| kindleEditionNormalizedPagesRoyalties14d |\n| newToBrandDetailPageViewRate |\n| newToBrandDetailPageViews |\n| newToBrandDetailPageViewsClicks |\n| newToBrandECPDetailPageView |\n| newToBrandPurchases |\n| newToBrandPurchasesClicks |\n| newToBrandPurchasesPercentage |\n| newToBrandPurchasesRate |\n| newToBrandSales |\n| newToBrandSalesClicks |\n| newToBrandSalesPercentage |\n| newToBrandUnitsSold |\n| newToBrandUnitsSoldClicks |\n| newToBrandUnitsSoldPercentage |\n| purchases |\n| purchasesClicks |\n| purchasesPromoted |\n| sales |\n| salesClicks |\n| salesPromoted |\n| startDate |\n| unitsSold |\n| unitsSoldClicks |\n| video5SecondViewRate |\n| video5SecondViews |\n| videoCompleteViews |\n| videoFirstQuartileViews |\n| videoMidpointViews |\n| videoThirdQuartileViews |\n| videoUnmutes |\n| viewabilityRate |\n| viewableImpressions |\n\n## Group by ads\n\n**Additional metrics**: N/A\n\n**Filters**:\n- adStatus (values: ENABLED, PAUSED, ARCHIVED)\n\n## Sample call\n\n```bash\ncurl --location 'https://advertising-api.amazon.com/reporting/reports' \\\n--header 'Content-Type: application/vnd.createasyncreportrequest.v3+json' \\\n--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxxxx' \\\n--header 'Amazon-Advertising-API-Scope: xxxxxxx' \\\n--header 'Authorization: Bearer Atza|xxxxxxxxxxx' \\\n--data '{\n    \"name\":\"SB advertised product report 9/5-9/10\",\n    \"startDate\":\"2023-09-05\",\n    \"endDate\":\"2023-09-10\",\n    \"configuration\":{\n        \"adProduct\":\"SPONSORED_BRANDS\",\n        \"groupBy\":[\"ads\"],\n        \"columns\":[\"impressions\",\"clicks\",\"cost\",\"campaignId\",\"adId\",\"adGroupId\"],\n        \"reportTypeId\":\"sbAds\",\n        \"timeUnit\":\"SUMMARY\",\n        \"format\":\"GZIP_JSON\"\n    }\n}'\n```\n\nFile v1.0.6:references/report-types/sb/sbCampaignPlacement.md\n\n---\nreportTypeId: sbCampaignPlacement\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/placement\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [campaign]\nformat: [GZIP_JSON]\nfilters: []\ndateRange:\n  maxSpanDays: 31\n  dataRetentionDays: 60\n---\n\n# SB Campaign Placement\n\nPlacement reports contain performance data broken down by ad placement.\n\n> **Note**\n> For Sponsored Products, there is not a separate placement report. You can get placement-level data using the 'campaignPlacement' groupBy in a campaign report.\n\n> **Note**\n> This report is currently available in preview. During the preview period, data related to Sponsored Brands campaigns with flag isMultiAdGroupsEnabled set to FALSE won't be available. Once version 3 reporting supports all Sponsored Brands campaigns, we will announce general availability in the release notes.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbCampaignPlacement |\n| Maximum date range | 31 days |\n| Data retention | 60 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | campaign |\n| format | GZIP_JSON |\n\n## Base metrics\n\n| Field |\n|------|\n| addToCart |\n| addToCartClicks |\n| addToCartRate |\n| addToList |\n| addToListFromClicks |\n| qualifiedBorrows |\n| qualifiedBorrowsFromClicks |\n| royaltyQualifiedBorrows |\n| royaltyQualifiedBorrowsFromClicks |\n| brandedSearches |\n| brandedSearchesClicks |\n| campaignBudgetAmount |\n| campaignBudgetCurrencyCode |\n| campaignBudgetType |\n| campaignId |\n| campaignName |\n| campaignStatus |\n| clicks |\n| cost |\n| costType |\n| date |\n| detailPageViews |\n| detailPageViewsClicks |\n| eCPAddToCart |\n| endDate |\n| impressions |\n| kindleEditionNormalizedPagesRead14d |\n| kindleEditionNormalizedPagesRoyalties14d |\n| newToBrandDetailPageViewRate |\n| newToBrandDetailPageViews |\n| newToBrandDetailPageViewsClicks |\n| newToBrandECPDetailPageView |\n| newToBrandPurchases |\n| newToBrandPurchasesClicks |\n| newToBrandPurchasesPercentage |\n| newToBrandPurchasesRate |\n| newToBrandSales |\n| newToBrandSalesClicks |\n| newToBrandSalesPercentage |\n| newToBrandUnitsSold |\n| newToBrandUnitsSoldClicks |\n| newToBrandUnitsSoldPercentage |\n| purchases |\n| purchasesClicks |\n| purchasesPromoted |\n| sales |\n| salesClicks |\n| salesPromoted |\n| startDate |\n| unitsSold |\n| unitsSoldClicks |\n| video5SecondViewRate |\n| video5SecondViews |\n| videoCompleteViews |\n| videoFirstQuartileViews |\n| videoMidpointViews |\n| videoThirdQuartileViews |\n| videoUnmutes |\n| viewabilityRate |\n| viewableImpressions |\n| viewClickThroughRate |\n\n## Group by campaignPlacement\n\n**Additional metrics**: placementClassification\n\n## Group by campaign\n\n**Additional metrics**: N/A\n\n## Sample call\n\n### Campaign placement summary report\n\n```bash\ncurl --location 'https://advertising-api.amazon.com/reporting/reports' \\\n--header 'Content-Type: application/vnd.createasyncreportrequest.v3+json' \\\n--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxxxx' \\\n--header 'Amazon-Advertising-API-Scope: xxxxxxx' \\\n--header 'Authorization: Bearer Atza|xxxxxxxx' \\\n--data '{\n    \"name\": \"SB placement report 9/5-9/10\",\n    \"startDate\": \"2023-09-05\",\n    \"endDate\": \"2023-09-10\",\n    \"configuration\": {\n        \"adProduct\": \"SPONSORED_BRANDS\",\n        \"groupBy\": [\n            \"campaignPlacement\"\n        ],\n        \"columns\": [\n            \"impressions\",\n            \"clicks\",\n            \"cost\",\n            \"campaignId\",\n            \"placementClassification\",\n            \"startDate\",\n            \"endDate\"\n        ],\n        \"reportTypeId\": \"sbCampaignPlacement\",\n        \"timeUnit\": \"SUMMARY\",\n        \"format\": \"GZIP_JSON\"\n    }\n}'\n```\n\nFile v1.0.6:references/report-types/sb/sbCampaigns.md\n\n---\nreportTypeId: sbCampaigns\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/campaign\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [campaign]\nformat: [GZIP_JSON]\nfilters:\n  - name: campaignStatus\n    values: [ENABLED, PAUSED, ARCHIVED]\n    applicableWhenGroupBy: [campaign]\ndateRange:\n  maxSpanDays: 31\n  dataRetentionDays: 60\n---\n\n# SB Campaigns\n\nCampaign reports contain performance data broken down at the campaign level. Campaign reports include all campaigns of the requested sponsored ad type that have performance activity for the requested days. For example, a Sponsored Products campaign report returns performance data for all Sponsored Products campaigns that received impressions on the chosen dates. Campaign reports can also be grouped by ad group and placement for more granular data.\n\n> **Note**\n> You can only use a filter that is supported by all groupBy values included in a report configuration. For campaign reports, this means that filters are only supported when you include a single groupBy value.\n\n> **Note**\n> This report currently available in preview. During the preview period, data related to Sponsored Brands campaigns with flag isMultiAdGroupsEnabled=False won't be available. Once version 3 reporting supports all Sponsored Brands campaigns, we will announce general availability in the release notes.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbCampaigns |\n| Maximum date range | 31 days |\n| Data retention | 60 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | campaign |\n| format | GZIP_JSON |\n\n## Base metrics\n\n| Field |\n|------|\n| addToCart |\n| addToCartClicks |\n| addToCartRate |\n| addToList |\n| addToListFromClicks |\n| qualifiedBorrows |\n| qualifiedBorrowsFromClicks |\n| royaltyQualifiedBorrows |\n| royaltyQualifiedBorrowsFromClicks |\n| brandedSearches |\n| brandedSearchesClicks |\n| campaignBudgetAmount |\n| campaignBudgetCurrencyCode |\n| campaignBudgetType |\n| campaignId |\n| campaignName |\n| campaignStatus |\n| clicks |\n| cost |\n| costType |\n| date |\n| detailPageViews |\n| detailPageViewsClicks |\n| eCPAddToCart |\n| endDate |\n| impressions |\n| kindleEditionNormalizedPagesRead14d |\n| kindleEditionNormalizedPagesRoyalties14d |\n| newToBrandDetailPageViewRate |\n| newToBrandDetailPageViews |\n| newToBrandDetailPageViewsClicks |\n| newToBrandECPDetailPageView |\n| brandStorePageView |\n| newToBrandPurchases |\n| newToBrandPurchasesClicks |\n| newToBrandPurchasesPercentage |\n| newToBrandPurchasesRate |\n| newToBrandSales |\n| newToBrandSalesClicks |\n| newToBrandSalesPercentage |\n| newToBrandUnitsSold |\n| newToBrandUnitsSoldClicks |\n| newToBrandUnitsSoldPercentage |\n| purchases |\n| purchasesClicks |\n| purchasesPromoted |\n| sales |\n| salesClicks |\n| salesPromoted |\n| startDate |\n| topOfSearchImpressionShare |\n| unitsSold |\n| unitsSoldClicks |\n| video5SecondViewRate |\n| video5SecondViews |\n| videoCompleteViews |\n| videoFirstQuartileViews |\n| videoMidpointViews |\n| videoThirdQuartileViews |\n| videoUnmutes |\n| viewabilityRate |\n| viewableImpressions |\n| viewClickThroughRate |\n\n## Group by campaign\n\n**Additional metrics**: campaignBudgetAmount, campaignBudgetCurrencyCode, campaignBudgetType, longTermSales, longTermROAS, topOfSearchImpressionShare\n\n**Filters**:\n- campaignStatus (values: ENABLED, PAUSED, ARCHIVED)\n\n## Sample calls\n\n### Campaign summary report grouped by campaign\n\n```bash\ncurl --location 'https://advertising-api.amazon.com/reporting/reports' \\\n--header 'Content-Type: application/vnd.createasyncreportrequest.v3+json' \\\n--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxx' \\\n--header 'Amazon-Advertising-API-Scope: xxxxxxxxx' \\\n--header 'Authorization: Bearer Atza|xxxxxxxxxx' \\\n--data '{\n    \"name\": \"SB campaigns report 9/5-9/10\",\n    \"startDate\": \"2023-09-05\",\n    \"endDate\": \"2023-09-10\",\n    \"configuration\": {\n        \"adProduct\": \"SPONSORED_BRANDS\",\n        \"groupBy\": [\n            \"campaign\"\n        ],\n        \"columns\": [\n            \"impressions\",\n            \"clicks\",\n            \"cost\",\n            \"campaignId\",\n            \"startDate\",\n            \"endDate\"\n        ],\n        \"reportTypeId\": \"sbCampaigns\",\n        \"timeUnit\": \"SUMMARY\",\n        \"format\": \"GZIP_JSON\"\n    }\n}'\n```\n\nFile v1.0.6:references/report-types/sb/sbGrossAndInvalids.md\n\n---\nreportTypeId: sbGrossAndInvalids\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/gross-and-invalid-traffic\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [campaign]\nformat: [GZIP_JSON, CSV]\nfilters:\n  - name: campaignStatus\n    values: [ENABLED, PAUSED, ARCHIVED]\n    applicableWhenGroupBy: [campaign]\ndateRange:\n  maxSpanDays: 365\n  dataRetentionDays: 365\n---\n\n# SB Gross and Invalid Traffic\n\nGross and invalid traffic report provides Sponsored Products, Sponsored Brands and Sponsored Display advertisers transparency into the nature of traffic on their campaigns. This report include all campaigns of the requested ad type and provides transparency on gross and invalid traffic metrics at campaign level for the requested days. For example, a Sponsored Products gross and invalid traffic report returns gross and invalid traffic metrics for all Sponsored Products campaigns that received impressions on the chosen dates.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbGrossAndInvalids |\n| Maximum date range | 365 days |\n| Data retention | 365 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | campaign |\n| format | GZIP_JSON or CSV |\n\n> Sponsored Products, Sponsored Brands, and Sponosred Display all support the same columns and configurations for the gross and invalid traffic report.\n\n## Base metrics\n\n| Field |\n|------|\n| campaignName |\n| campaignStatus |\n| clicks |\n| date |\n| endDate |\n| grossClickThroughs |\n| grossImpressions |\n| impressions |\n| invalidClickThroughRate |\n| invalidClickThroughs |\n| invalidImpressionRate |\n| invalidImpressions |\n| startDate |\n\n## Group by campaign\n\n**Additional metrics**: N/A\n\n**Filters**:\n- campaignStatus (values: ENABLED, PAUSED, ARCHIVED)\n\nFile v1.0.6:references/report-types/sb/sbPromptAdExtension.md\n\n---\nreportTypeId: sbPromptAdExtension\nadProduct: SPONSORED_BRANDS\nofficialDocUrl: https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/prompt-ad-extension\ntimeUnit: [SUMMARY, DAILY]\ngroupBy: [promptAdExtension]\nformat: [GZIP_JSON, XLSX]\nfilters:\n  - name: marketplaceId\n    values: [US]\n    applicableWhenGroupBy: [promptAdExtension]\ndateRange:\n  maxSpanDays: 90\n  dataRetentionDays: 95\n---\n\n# SB Prompt Ad Extension\n\nPrompt Ad Extension reports contain performance data for Sponsored Products and Sponsored Brands ads that include metrics for AI-powered prompt ads. Prompts are designed to help shoppers discover products through conversational experiences on Amazon by surfacing relevant product information through intelligent suggestions and guiding questions.\n\n## About Prompts\n\nPrompts are a new ad format that integrates into your existing Sponsored Products and Sponsored Brands campaigns with zero additional setup required. They enhance product discovery at crucial shopper decision points by:\n\n- Showcasing your product expertise at scale during critical shopper decision moments\n- Engaging high-intent shoppers with relevant product information\n- Anticipating and answering shopper questions about your products\n\nPrompts with clicks will show in your existing Sponsored Products or Sponsored Brands reporting, and you can pause individual prompts through the Amazon Ads console.\n\n## Configuration\n\n| Configuration | Value |\n|---|---|\n| reportTypeId | sbPromptAdExtension |\n| Maximum date range | 90 days |\n| Data retention | 95 days |\n| timeUnit | SUMMARY or DAILY |\n| groupBy | promptAdExtension |\n| format | GZIP_JSON or XLSX |\n\n## Base metrics\n\n| Field |\n|------|\n| date |\n| startDate |\n| endDate |\n| campaignId |\n| campaignName |\n| adGroupId |\n| adGroupName |\n| marketplaceId |\n| adId |\n| adName |\n| creativeExtensionId |\n| creativeExtensionType |\n| portfolioName |\n| campaignBudgetCurrencyCode |\n| promptText |\n| impressions |\n| clicks |\n| clickThroughRate |\n| costPerClick |\n| cost |\n| spend |\n| viewableImpressions |\n| acosClicks7d |\n| acosClicks14d |\n| roasClicks7d |\n| roasClicks14d |\n| purchases1d |\n| purchases7d |\n| purchases14d |\n| purchases30d |\n| purchasesSameSku1d |\n| purchasesSameSku7d |\n| purchasesSameSku14d |\n| purchasesSameSku30d |\n| purchasesOtherSku1d |\n| purchasesOtherSku7d |\n| purchasesOtherSku14d |\n| purchasesOtherSku30d |\n| unitsSoldClicks1d |\n| unitsSoldClicks7d |\n| unitsSoldClicks14d |\n| unitsSoldClicks30d |\n| unitsSoldSameSku1d |\n| unitsSoldSameSku7d |\n| unitsSoldSameSku14d |\n| unitsSoldSameSku30d |\n| unitsSoldOtherSku1d |\n| unitsSoldOtherSku7d |\n| unitsSoldOtherSku14d |\n| unitsSoldOtherSku30d |\n| sales1d |\n| sales7d |\n| sales14d |\n| sales30d |\n| attributedSalesSameSku1d |\n| attributedSalesSameSku7d |\n| attributedSalesSameSku14d |\n| attributedSalesSameSku30d |\n| salesOtherSku1d |\n| salesOtherSku7d |\n| salesOtherSku14d |\n| salesOtherSku30d |\n| purchaseClickRate7d |\n| purchaseClickRate14d |\n| newToBrandPurchases |\n| newToBrandPurchasesPercentage |\n| newToBrandUnitsSold |\n| newToBrandUnitsSoldPercentage |\n| newToBrandSales |\n| newToBrandSalesPercentage |\n\n## Group by promptAdExtension\n\n**Additional metrics**: N/A\n\n**Filters**:\n- marketplaceId (values: US)\n\n## Sample call\n\n```bash\ncurl --location 'https://advertising-api.amazon.com/reporting/reports' \\\n--header 'Content-Type: application/vnd.createasyncreportrequest.v3+json' \\\n--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxxxx' \\\n--header 'Amazon-Advertising-API-Scope: xxxxxxx' \\\n--header 'Authorization: Bearer Atza|xxxxxxxxxxx' \\\n--data '{\n    \"name\":\"SB prompt ad extension report 4/13-4/16\",\n    \"startDate\":\"2026-04-13\",\n    \"endDate\":\"2026-04-16\",\n    \"configuration\":{\n        \"adProduct\":\"SPONSORED_BRANDS\",\n        \"groupBy\":[\"promptAdExtension\"],\n        \"columns\":[\"date\",\"campaignId\",\"campaignName\",\"adGroupId\",\"adGroupName\",\"adId\",\"adName\",\"creativeExtensionId\",\"promptText\",\"impressions\",\"clicks\",\"cost\",\"purchases7d\",\"sales7d\",\"newToBrandPurchases\",\"newToBrandSales\"],\n        \"reportTypeId\":\"sbPromptAdExtension\",\n        \"timeUnit\":\"DAILY\",\n        \"format\":\"GZIP_JSON\"\n    }\n}'\n```\n\nArchive v1.0.5: 32 files, 63056 bytes\n\nFiles: references/api.md (10759b), references/report-types/index.md (552b), references/report-types/sb/index.md (562b), references/report-types/sb/sbAdGroup.md (4001b), references/report-types/sb/sbAds.md (3314b), references/report-types/sb/sbCampaignPlacement.md (3673b), references/report-types/sb/sbCampaigns.md (4286b), references/report-types/sb/sbGrossAndInvalids.md (1786b), references/report-types/sb/sbPromptAdExtension.md (4170b), references/report-types/sb/sbPurchasedProduct.md (2262b), references/report-types/sb/sbSearchTerm.md (3788b), references/report-types/sb/sbTargeting.md (4330b), references/report-types/sd/index.md (426b), references/report-types/sd/sdAdGroup.md (3664b), references/report-types/sd/sdAdvertisedProduct.md (3473b), references/report-types/sd/sdCampaigns.md (3878b), references/report-types/sd/sdGrossAndInvalids.md (2544b), references/report-types/sd/sdPurchasedProduct.md (2742b), references/report-types/sd/sdTargeting.md (4672b), references/report-types/sp/index.md (494b), references/report-types/sp/spAdvertisedProduct.md (2794b), references/report-types/sp/spCampaigns.md (6362b), references/report-types/sp/spGrossAndInvalids.md (2747b), references/report-types/sp/spPromptAdExtension.md (3887b), references/report-types/sp/spPurchasedProduct.md (2869b), references/report-types/sp/spSearchTerm.md (4766b), references/report-types/sp/spTargeting.md (5365b), scripts/check_auth_dependency.py (6741b), scripts/get_report.py (33252b), skill-card.md (2490b), SKILL.md (14852b), _meta.json (144b)\n\nFile v1.0.5:SKILL.md\n\n---\nname: linkfox-amazon-ads-report\ndescription: 亚马逊广告（Amazon Ads）报告一站式获取技能，覆盖 Sponsored Products (SP) / Sponsored Brands (SB) / Sponsored Display (SD) 全部报告类型。脚本自动完成报告的创建、等待、下载和解压，直接返回可读的结构化数据。真实可用的报告类型及每类的列清单/groupBy/filters 以 `references/report-types/<adProduct-dir>/<reportTypeId>.md` 为单一真相源。当用户提到拉取亚马逊广告报告、下载 Amazon Ads 报告、获取 SP/SB/SD 广告活动/关键词/搜索词/投放商品/购买商品/广告组/流量异常/Prompt 扩展等任意报告时触发。本技能依赖 linkfox-amazon-ads-auth。Sponsored Television (ST) / Amazon DSP 暂未覆盖。\n---\n\n# Amazon Ads 报告获取\n\n报告一站式获取：脚本自动完成报告的创建、等待（约 2–10 分钟）、下载和解压，直接返回可读的结构化数据。\n脚本本身不做\"该选哪些列 / 该怎么分组\"的业务判断，这些由 agent 先查 `references/report-types/` 下对应的 `.md` 文件，再显式传给脚本。\n\n**依赖 `linkfox-amazon-ads-auth`**（脚本启动自动检查；未安装时 exit 42，stderr 打 `DEPENDENCY_MISSING`）。\n\n### ⚠️ 多账号场景：调用前必须解析好 profileId\n\n用户经常只说自然语言（\"美国站\"、\"日本站\"、\"我的店铺\"），本 skill 的所有脚本都必须拿到数字 `profileId` 才能调。按下列顺序处理，**不要跳过**：\n\n1. 先调 `linkfox-amazon-ads-auth` 的 `authorized_stores.py` 拉出用户已授权的账号 × 站点清单。\n2. 根据用户提到的站点（映射到 `countryCode`，如 美国→`US`）匹配候选 profile：\n   - **只有 1 个候选** → 静默取对应 profileId，继续调用；不要把 profileId 数字播报给用户。\n   - **≥ 2 个候选（同站点下多个授权账号）** → **必须向用户澄清**，用 `accountName` 问：\"你在美国站授权了 A 和 B 两个账号，这次用哪个？\"\n   - **0 个候选** → 告知用户该站点未授权，引导去 `linkfox-amazon-ads-auth` 做授权。\n3. **严禁**让用户直接报 profileId 数字。\n4. **严禁**在歧义下\"挑第一个\"或\"选默认\"绕过澄清。\n\n完整决策表见 `linkfox-amazon-ads-auth` SKILL.md 的 **Usage Scenarios 第 4 节**。\n\n## 调用方式\n\n- **API 端点**：`POST /amazonAds/developerProxy`（不同操作通过请求体区分；完整参数/响应/错误码见 `references/api.md`）\n- **Python 脚本**：`python scripts/<脚本名>.py '<JSON 参数>' [--inline]`（可用脚本见上文脚本一览）\n- **成本约束**：本工具会消耗积分；失败/空结果不得自动换关键词、翻页或连续试探；需要继续检索时先向用户说明会产生额外消耗。\n\n**输出策略（脚本默认行为）**：\n- **始终**将完整响应写入 `<cwd>/linkfox/<YYYY-MM-DD>/<session>/data/<skill-name>-<timestamp>.json`（`<cwd>` 为脚本执行时的工作目录，在 Claude Code 里即当前项目目录；`<session>` 取自环境变量 `SESSION_ID`，按用户任务自动聚合；**禁止写入 /tmp**，当前目录不可写则报错）\n- 响应体 ≤ 8 KB：落盘后把完整 JSON 打印到 stdout\n- 响应体 > 8 KB：落盘后 stdout 只输出摘要（顶层字段、常见计数如 `total`/`costToken`、最大列表字段的长度 + 前 3 条样本）\n- 加 `--inline` 强制全量打印到 stdout（同样落盘）\n\n**读数据建议**：先看摘要判断是否足够；需要具体字段时优先用 `jq`或`ConvertFrom-Json`或`ConvertFrom-Json` 从保存的 json 文件按需抽取，避免整份 JSON 进入上下文。\n\n## 解决认证和积分问题\n发生以下异常情况时，采用以下措施来处理：\n\n### 异常情况\n- **未配置API Key**：环境变量未配置 `LINKFOX_AGENT_API_KEY`，也未配置 `LINKFOXAGENT_API_KEY`。\n- **响应401或402状态码**\n- **响应提示积分或余额不足**：消息含\"积分余额不足/计费不足/余额不足/quota exceeded/insufficient balance/套餐到期/需充值/请充值\"，或类似含义的内容。\n\n### 措施\n- 优先采用skill内的 onboarding.md 引导解决问题。\n- 如找不到 onboarding.md 文件，则加载 /linkfox-onboarding 这个skill并根据它的引导来处理。如未安装请先安装：\n    - 下载 https://agent-files.linkfox.com/skills/linkfox-onboarding/release.zip，解压后安装这个skill。如需用户授权才可下载，要询问用户获得授权，你不能自己放弃下载。\n- 兜底措施：仅当前面两个措施经过所有努力都走不通时，才提示用户依据 https://skill.linkfox.com/linkfoxskills/guide.htm 指引获取API Key，或去 https://os.linkfox.com/ 补充积分。\n\n## Core Concepts\n\n- **覆盖**：SP / SB / SD 全部报告类型（以 `references/report-types/` 下存在的 `.md` 为准；ST / DSP 暂未覆盖）\n- **一站式**：脚本内部自动完成报告创建 → 等待生成（约 2–10 分钟）→ 下载 → 解压，调用方只需等最终结果\n- **单脚本**：`get_report.py`（覆盖 SP / SB 全部 adProduct）\n- **元数据 vs. 运行参数**：\n  - 每个报告类型的**可用字段**（timeUnit / groupBy / filters / 全部列名）集中在 `references/report-types/<adProduct-dir>/<reportTypeId>.md`\n  - **脚本运行参数**（等待间隔、访问链接时效等）见本文件和 `references/api.md`\n\n## 可用脚本\n\n| 脚本 | 职责 |\n|------|------|\n| `get_report.py` ⭐ | 一站式执行。**必填** `adProduct` / `groupBy` / `columns`，由 agent 从 report-types/ 提取后传入 |\n| `check_auth_dependency.py` | 检测 linkfox-amazon-ads-auth 是否安装 |\n\n完整脚本参数、响应结构见 `references/api.md`。\n\n## Agent 调用流程\n\nAgent 触达\"拉取亚马逊广告报告\"类需求时，**必须**按下列顺序：\n\n1. **定 reportTypeId**：按用户意图挑选（如\"上周花费\"→ `spCampaigns`；\"哪个商品卖得好\"→ `spAdvertisedProduct` / `sbPurchasedProduct`；\"用户搜什么词找到我\"→ `spSearchTerm`）\n2. **查 reference**：打开 `references/report-types/<adProduct-dir>/<reportTypeId>.md`\n   - **frontmatter** 给出：`adProduct` / `groupBy`（Configuration 表推荐的） / `timeUnit`(可枚举) / `format` / `dateRange` / `filters`\n   - **Base metrics 表** 给出：此报告类型允许的全部列名\n3. **向用户咨询可定制条件**（用户答\"默认/随便\"时跳过，进入第 4 步的默认选择）：\n   - `timeUnit`：DAILY（按日拆分）还是 SUMMARY（汇总）\n   - `columns` 扩展：是否要归因列（sales7d / purchases7d / acosClicks7d / roasClicks7d）、视频指标、newToBrand 等\n   - `filters`：是否过滤 campaignStatus / keywordType / adStatus 等\n4. **按用户回复或默认构造 columns**（见下节 \"默认条件\"）\n5. **调脚本**：`adProduct` / `groupBy` / `columns` 三个必填字段**显式**传入\n\n## 默认条件（用户未指定时使用）\n\n| 条件 | 默认规则 |\n|------|---------|\n| `timeUnit` | 日期跨度 ≤ 7 天 → `DAILY`；> 7 天 → `SUMMARY` |\n| `columns` 身份维度 | `DAILY` 时必含 `date`；`SUMMARY` 时必含 `startDate` + `endDate`；再追加该报告的主键字段（参考 frontmatter 中 groupBy 对应的主键，如 campaignId+campaignName / advertisedAsin+advertisedSku / searchTerm / keyword 等） |\n| `columns` 基础指标 | `impressions` / `clicks` / `cost`（以该报告 Base metrics 存在的为准） |\n| `columns` 归因指标 | **仅当用户提到\"销售/转化/ROI/ACOS\"等意图时追加**：`sales7d` / `purchases7d` / `acosClicks7d` / `roasClicks7d`（以 Base metrics 存在者为准） |\n| `filters` | 不加（全量返回） |\n| `groupBy` | 取 frontmatter `groupBy` 数组的第一个值（即 Configuration 表里 Amazon 官方推荐的主维度） |\n\n## 请求示例\n\n所有 example 都显式传入三个必填字段（`adProduct` / `groupBy` / `columns`）。\n\n### 1. SP 广告活动报告（最常见）\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"adProduct\": \"SPONSORED_PRODUCTS\",\n  \"groupBy\": [\"campaign\"],\n  \"columns\": [\"date\",\"campaignId\",\"campaignName\",\"impressions\",\"clicks\",\"cost\"],\n  \"startDate\": \"2026-04-27\",\"endDate\": \"2026-05-03\",\n  \"timeUnit\": \"DAILY\"\n}'\n```\n\n### 2. SP 搜索词报告（含归因）\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"spSearchTerm\",\n  \"adProduct\": \"SPONSORED_PRODUCTS\",\n  \"groupBy\": [\"searchTerm\"],\n  \"columns\": [\"searchTerm\",\"keyword\",\"matchType\",\"impressions\",\"clicks\",\"cost\",\n              \"sales7d\",\"sales14d\",\"purchases7d\",\"acosClicks14d\",\"roasClicks14d\",\n              \"startDate\",\"endDate\"],\n  \"startDate\": \"2026-04-01\",\"endDate\": \"2026-04-30\",\n  \"timeUnit\": \"SUMMARY\",\n  \"filters\": [{\"field\":\"keywordType\",\"values\":[\"BROAD\",\"PHRASE\",\"EXACT\"]}]\n}'\n```\n\n### 3. SB 广告组报告\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"sbAdGroup\",\n  \"adProduct\": \"SPONSORED_BRANDS\",\n  \"groupBy\": [\"adGroup\"],\n  \"columns\": [\"adGroupId\",\"adGroupName\",\"impressions\",\"clicks\",\"cost\",\"purchases\",\"sales\",\"startDate\",\"endDate\"],\n  \"startDate\": \"2026-04-01\",\"endDate\": \"2026-04-30\"\n}'\n```\n\n### 4. SD 广告活动报告\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"sdCampaigns\",\n  \"adProduct\": \"SPONSORED_DISPLAY\",\n  \"groupBy\": [\"campaign\"],\n  \"columns\": [\"date\",\"campaignId\",\"campaignName\",\"impressions\",\"clicks\",\"cost\",\"purchases\",\"sales\"],\n  \"startDate\": \"2026-04-27\",\"endDate\": \"2026-05-03\",\n  \"timeUnit\": \"DAILY\"\n}'\n```\n\n### 5. 轮询一个已有 reportId（救回上次超时 / 手工恢复）\n\n当上次运行因为客户端轮询窗口太短退出、但报告在 Amazon 侧仍在跑时，直接传入 `reportId` 即可跳过创建，继续轮询并下载。此模式下只需 `profileId` / `region` / `reportId`，其余字段不必填。\n\n```bash\npython scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportId\": \"7df1ef5d-45ba-40cc-b607-ff2148cf4f5e\",\n  \"maxAttempts\": 60, \"pollInterval\": 30\n}'\n```\n\n> **自动恢复**：如果调用方未传 `reportId`、且 Amazon 对同参数请求触发去重（返回 HTTP 425 `The Request is a duplicate of : <uuid>`），脚本会自动解析出老 reportId 并转为轮询该老报告，无需重试。\n\n## 响应格式\n\n成功：\n```json\n{\n  \"success\": true,\n  \"reportId\": \"4ee811a0-...\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"startDate\": \"2026-04-28\", \"endDate\": \"2026-05-04\",\n  \"downloadPath\": \"C:/.../tmp/report_data.json\",\n  \"extractedFileHttpUrl\": \"http://127.0.0.1:51234/download\",\n  \"extractedFileHttpServeSeconds\": 300\n}\n```\n\n失败：\n```json\n{\"error\":\"Upstream HTTP 400\",\"httpStatus\":400,\n \"body\":\"{\\\"code\\\":\\\"400\\\",\\\"detail\\\":\\\"startDate to endDate range (32 days) must not exceed maximum range (31 days)\\\"}\"}\n```\n\n## 调用原则\n\n- 用户指定了 reportTypeId 就只拉那一种，不擅自替换\n- 报告失败（非 2xx 或 status=FAILED）时如实告知错误原因，不盲目重试\n- 成功后把报告的本地文件路径和访问链接完整展示给用户，并提醒访问链接有时效（默认 5 分钟内有效，过期需重新拉取）\n- **超时不是失败**：当脚本返回 `status=STILL_PROCESSING`（exit code=2），说明客户端已等满默认 10 分钟但报告仍在 Amazon 侧生成。此时 **必须**向用户说明情况并询问是否继续等待，绝不能当成失败处理。参考回复：\"报告还在 Amazon 侧生成中（已等 10 分钟），要继续等吗？可以选：A. 再等 ~20 分钟（maxAttempts=60）、B. 再等 ~1 小时（maxAttempts=120）、C. 先停，我稍后用 reportId 回来。\" 用户选 A/B → 用 `resumeHint.params` 切到仅轮询模式续跑\n\n## 常见错误\n\n| 状态 | 含义 | 建议 |\n|------|------|------|\n| `Missing required parameters: adProduct/groupBy/columns` | 调用方未显式传入三必填 | 回到 \"Agent 调用流程\" 第 2 步，从 `references/report-types/<adProduct-dir>/<reportTypeId>.md` 读出并补上 |\n| `HTTP 401` | accessToken 过期 | 调 ads-auth 的 `refresh_token.py` 后重试 |\n| `HTTP 403` | 未关联广告账户或权限不足 | 到 Amazon Ads 后台检查经理账户/广告账户关联 |\n| `HTTP 400 \"must not exceed maximum range\"` | 日期跨度超限（多数 31 天） | 拆分拉取后本地合并；具体上限看对应 `.md` frontmatter `dateRange.maxSpanDays` |\n| `HTTP 400` 含 `columns`/`groupBy` 校验错 | 列名拼写错 / 与 reportTypeId 不匹配 / 超出 Base metrics | 对照 `.md` 文件 Base metrics 表核对 |\n| `status=FAILED` 含 `failureReason` | 上游生成失败 | 多为日期窗口或权限问题，按 failureReason 具体处理 |\n| `status=STILL_PROCESSING` (exit 2) | 客户端轮询窗口耗尽但报告仍在生成 | **不是失败**。stdout 已含 `reportId` 与 `resumeHint.params`。询问用户是否继续等，用该 params（带 `reportId` + 更大 `maxAttempts`）切到仅轮询模式续跑 |\n| `HTTP 425 \"duplicate of\"` | 同参数已有在跑的报告 | 脚本自动解析并转为轮询该老 reportId，正常情况下调用方无需干预 |\n| exit 42 | 依赖 skill 未安装 | 先装 `linkfox-amazon-ads-auth` |\n\n## 日期与数据\n\n- **日期跨度上限**：多数报告 31 天；`sbPurchasedProduct` 是 731 天；`spGrossAndInvalids` / `sbGrossAndInvalids` / `sdGrossAndInvalids` 是 365 天（以 frontmatter 为准）\n- **回溯窗口**：SP 默认 95 天、SB 60 天、GrossAndInvalids 365 天；具体以 frontmatter `dateRange.dataRetentionDays` 为准\n- **数据延迟约 12 小时**；`endDate >= 今天` 脚本 stderr 警告但不拦截\n- **空数据不等于报错**：账号当期无投放时报告会成功生成，JSON 可能为 `[]` 或指标全 0\n\n## Not Applicable\n\n- Brand Analytics / Retail Analytics / Attribution 报告 → 不在本 skill\n- 报告删除 / 修改 / 定时任务 → 不在本 skill\n- 实体元数据（campaign 名、keyword 匹配类型等）→ `linkfox-amazon-ads-manager`\n- 授权 / token → `linkfox-amazon-ads-auth`\n\n## 积分消耗规则\n\n不消耗积分。\n\n**Feedback:**\n\nAuto-detect and report feedback via the Feedback API when any of the following apply:\n1. The functionality or purpose described in this skill does not match actual behavior\n2. The skill's results do not match the user's intent\n3. The user expresses dissatisfaction or praise about this skill\n4. Anything you believe could be improved\n\nCall the feedback API as specified in `references/api.md`. Do not interrupt the user's flow.\n\n---\n*For more high-quality, professional cross-border e-commerce skills, visit [LinkFox Skills](https://skill.linkfox.com/).*\n\nFile v1.0.5:_meta.json\n\n{\n  \"ownerId\": \"kn7dmc1t4j28hem1twwyav85p182pb1j\",\n  \"slug\": \"linkfox-amazon-ads-report\",\n  \"version\": \"1.0.5\",\n  \"publishedAt\": 1783944144998\n}\n\nFile v1.0.5:references/api.md\n\n# linkfox-amazon-ads-report — 参数与字段参考\n\nAmazon Ads 报告自动化获取（SP / SB 覆盖；SD / ST / DSP 暂未覆盖）。授权见 `linkfox-amazon-ads-auth`；广告管理见 `linkfox-amazon-ads-manager`。\n\n> **📌 报告类型的真相源**：每个 `reportTypeId` 的完整规格（可用 columns / groupBy / filters / timeUnit / 日期约束 / 官方示例）在 `references/report-types/<adProduct-dir>/<reportTypeId>.md`，**按 adProduct 分目录**：\n> - `report-types/sp/`（Sponsored Products）\n> - `report-types/sb/`（Sponsored Brands）\n>\n> 目录总览见 `report-types/index.md`。本文件仅给运行时脚本参数与通用规则。\n\n## 支持的报告类型\n\n完整列表见 `report-types/index.md` 及各 adProduct 子目录下的 `index.md`。常用快速索引：\n\n| reportTypeId | 业务含义 | 文件 |\n|--------------|---------|------|\n| `spCampaigns` | 广告活动级（SP） | `report-types/sp/spCampaigns.md` |\n| `spAdvertisedProduct` | 投放商品级（SP） | `report-types/sp/spAdvertisedProduct.md` |\n| `spSearchTerm` | 搜索词级（SP） | `report-types/sp/spSearchTerm.md` |\n| `spTargeting` | 定向/关键词级（SP） | `report-types/sp/spTargeting.md` |\n| `sbCampaigns` / `sbAdGroup` / `sbAds` / ... | Sponsored Brands | `report-types/sb/*.md` |\n\n## 输入参数\n\n脚本支持两种模式：\n\n- **全链路模式（默认）**：创建报告 → 轮询 → 下载。需要下表全部必填字段。\n- **仅轮询模式**：入参中显式传入 `reportId`（见下方\"可选流程参数\"），跳过创建，只需 `profileId` / `region`，其余全部可省略。用于救回上次客户端超时但报告仍在跑的场景。\n\n### 必填（全链路模式）\n\n| 参数 | 类型 | 说明 |\n|------|------|------|\n| `profileId` | number | 从 ads-auth 获取 |\n| `region` | string | `NA` / `EU` / `FE` |\n| `reportTypeId` | string | 见 `report-types/index.md` 各 adProduct 子目录下的完整列表 |\n| `adProduct` | string | 取自对应 `.md` 文件的 frontmatter（`SPONSORED_PRODUCTS` / `SPONSORED_BRANDS`）|\n| `groupBy` | list | 取自对应 `.md` 文件的 frontmatter |\n| `columns` | list | 取自对应 `.md` 文件 Base metrics 表的子集 |\n| `startDate` | string | `YYYY-MM-DD`（含当天） |\n| `endDate` | string | `YYYY-MM-DD`（含当天） |\n\n### 可选业务参数\n\n| 参数 | 默认 | 说明 |\n|------|------|------|\n| `name` | `{reportTypeId}_{startDate}_{endDate}` | 报告显示名 |\n| `timeUnit` | `SUMMARY` | `DAILY`（每天一行） / `SUMMARY`（整期一行） |\n| `format` | `GZIP_JSON` | 响应文件格式 |\n| `filters` | 空 | 过滤条件数组，字段与取值见对应 `.md` 文件 |\n\n### 可选流程参数\n\n| 参数 | 默认 | 说明 |\n|------|------|------|\n| `reportId` | 无 | 若显式传入，脚本进入**仅轮询模式**：跳过创建步骤，直接对该 reportId 轮询与下载。此时只要 `profileId` / `region` + `reportId`，其他字段可省 |\n| `pollInterval` | 30 | 轮询间隔秒 |\n| `maxAttempts` | 20 | 最大轮询次数（默认 10 分钟上限） |\n| `skipDepCheck` | false | 跳过依赖检查 |\n| `serveExtractedFileHttp` | true | 是否启本机 HTTP 服务 |\n| `serveHost` | `127.0.0.1` | 绑定地址（仅本机可访问） |\n| `servePort` | 0 | 端口（0=系统分配） |\n| `serveSeconds` | 300 | HTTP 服务存活秒 |\n| `includeAmazonSourceUrl` | false | 响应中带预签名 URL |\n\n## 日期限制\n\n- **跨度上限**：以对应 `.md` 文件 frontmatter 的 `dateRange.maxSpanDays` 为准（多数 31 天；`sbPurchasedProduct` 731 天；GrossAndInvalids 系列 365 天）。超出返回 HTTP 400 `\"must not exceed maximum range\"`。\n- **回溯上限**：以 `dateRange.dataRetentionDays` 为准（SP 多为 95 天，SB 60 天）。\n- **数据延迟**：~12 小时；`endDate >= 今天` 脚本会 stderr 警告但不拦截。建议 `endDate <= 昨天`。\n\n## 各报告类型的列\n\n每个 reportTypeId 的完整 Base metrics 列表、allowed groupBy、filters 枚举值，统一在 `report-types/<adProduct-dir>/<reportTypeId>.md` 中维护：\n\n- `.md` 的 **frontmatter** 提供 `adProduct` / `groupBy` / `timeUnit`（可选值）/ `format` / `filters` / `dateRange`\n- **Base metrics 表**列出此报告类型支持的**全部列名**；调用方按业务需要选子集\n\n归因窗口后缀约定：`_1d` / `_7d` / `_14d` / `_30d` 表示 1/7/14/30 天归因窗口（点击或曝光归因的销售额、订单量、件数等）。具体每个字段支持哪些窗口，以对应 `.md` 文件的 Base metrics 表为准（不是所有字段都有全部 4 个窗口版本）。\n\n## 工作流与输出\n\n脚本流程：依赖检查 → 取 token → 创建报告 → 等待生成（每 `pollInterval` 秒查询一次状态）→ 下载 GZIP_JSON（Amazon 预签名 URL 约 1 小时有效）→ 解压为可读 JSON → 通过本机 `127.0.0.1` 上的临时 HTTP 服务对调用方暴露（`serveSeconds` 后自动关闭）→ 输出调用结果 JSON（含本地文件路径与访问链接）。\n\n`status` 枚举：`PENDING` / `PROCESSING` / `COMPLETED` / `FAILED`。\n\n### 成功响应\n\n```json\n{\n  \"success\": true,\n  \"reportId\": \"4ee811a0-6aaa-4ceb-9d31-d3bce\n\nArchive v1.0.4: 32 files, 62400 bytes\n\nFiles: references/api.md (10604b), references/report-types/index.md (552b), references/report-types/sb/index.md (562b), references/report-types/sb/sbAdGroup.md (4001b), references/report-types/sb/sbAds.md (3314b), references/report-types/sb/sbCampaignPlacement.md (3673b), references/report-types/sb/sbCampaigns.md (4286b), references/report-types/sb/sbGrossAndInvalids.md (1786b), references/report-types/sb/sbPromptAdExtension.md (4170b), references/report-types/sb/sbPurchasedProduct.md (2262b), references/report-types/sb/sbSearchTerm.md (3788b), references/report-types/sb/sbTargeting.md (4330b), references/report-types/sd/index.md (426b), references/report-types/sd/sdAdGroup.md (3664b), references/report-types/sd/sdAdvertisedProduct.md (3473b), references/report-types/sd/sdCampaigns.md (3878b), references/report-types/sd/sdGrossAndInvalids.md (2544b), references/report-types/sd/sdPurchasedProduct.md (2742b), references/report-types/sd/sdTargeting.md (4672b), references/report-types/sp/index.md (494b), references/report-types/sp/spAdvertisedProduct.md (2794b), references/report-types/sp/spCampaigns.md (6362b), references/report-types/sp/spGrossAndInvalids.md (2747b), references/report-types/sp/spPromptAdExtension.md (3887b), references/report-types/sp/spPurchasedProduct.md (2869b), references/report-types/sp/spSearchTerm.md (4766b), references/report-types/sp/spTargeting.md (5365b), scripts/check_auth_dependency.py (6741b), scripts/get_report.py (33211b), skill-card.md (2260b), SKILL.md (13718b), _meta.json (144b)\n\nArchive v1.0.3: 31 files, 61179 bytes\n\nFiles: references/api.md (10604b), references/report-types/index.md (552b), references/report-types/sb/index.md (562b), references/report-types/sb/sbAdGroup.md (4001b), references/report-types/sb/sbAds.md (3314b), references/report-types/sb/sbCampaignPlacement.md (3673b), references/report-types/sb/sbCampaigns.md (4286b), references/report-types/sb/sbGrossAndInvalids.md (1786b), references/report-types/sb/sbPromptAdExtension.md (4170b), references/report-types/sb/sbPurchasedProduct.md (2262b), references/report-types/sb/sbSearchTerm.md (3788b), references/report-types/sb/sbTargeting.md (4330b), references/report-types/sd/index.md (426b), references/report-types/sd/sdAdGroup.md (3664b), references/report-types/sd/sdAdvertisedProduct.md (3473b), references/report-types/sd/sdCampaigns.md (3878b), references/report-types/sd/sdGrossAndInvalids.md (2544b), references/report-types/sd/sdPurchasedProduct.md (2742b), references/report-types/sd/sdTargeting.md (4672b), references/report-types/sp/index.md (494b), references/report-types/sp/spAdvertisedProduct.md (2794b), references/report-types/sp/spCampaigns.md (6362b), references/report-types/sp/spGrossAndInvalids.md (2747b), references/report-types/sp/spPromptAdExtension.md (3887b), references/report-types/sp/spPurchasedProduct.md (2869b), references/report-types/sp/spSearchTerm.md (4766b), references/report-types/sp/spTargeting.md (5365b), scripts/check_auth_dependency.py (6741b), scripts/get_report.py (33211b), SKILL.md (13718b), _meta.json (144b)\n\nArchive v1.0.2: 31 files, 61169 bytes\n\nFiles: references/api.md (10604b), references/report-types/index.md (552b), references/report-types/sb/index.md (562b), references/report-types/sb/sbAdGroup.md (4001b), references/report-types/sb/sbAds.md (3314b), references/report-types/sb/sbCampaignPlacement.md (3673b), references/report-types/sb/sbCampaigns.md (4286b), references/report-types/sb/sbGrossAndInvalids.md (1786b), references/report-types/sb/sbPromptAdExtension.md (4170b), references/report-types/sb/sbPurchasedProduct.md (2262b), references/report-types/sb/sbSearchTerm.md (3788b), references/report-types/sb/sbTargeting.md (4330b), references/report-types/sd/index.md (426b), references/report-types/sd/sdAdGroup.md (3664b), references/report-types/sd/sdAdvertisedProduct.md (3473b), references/report-types/sd/sdCampaigns.md (3878b), references/report-types/sd/sdGrossAndInvalids.md (2544b), references/report-types/sd/sdPurchasedProduct.md (2742b), references/report-types/sd/sdTargeting.md (4672b), references/report-types/sp/index.md (494b), references/report-types/sp/spAdvertisedProduct.md (2794b), references/report-types/sp/spCampaigns.md (6362b), references/report-types/sp/spGrossAndInvalids.md (2747b), references/report-types/sp/spPromptAdExtension.md (3887b), references/report-types/sp/spPurchasedProduct.md (2869b), references/report-types/sp/spSearchTerm.md (4766b), references/report-types/sp/spTargeting.md (5365b), scripts/check_auth_dependency.py (6741b), scripts/get_report.py (33212b), SKILL.md (13718b), _meta.json (144b)\n\nArchive v1.0.1: 32 files, 59824 bytes\n\nFiles: references/api.md (10603b), references/report-types/index.md (552b), references/report-types/sb/index.md (562b), references/report-types/sb/sbAdGroup.md (4001b), references/report-types/sb/sbAds.md (3314b), references/report-types/sb/sbCampaignPlacement.md (3673b), references/report-types/sb/sbCampaigns.md (4286b), references/report-types/sb/sbGrossAndInvalids.md (1786b), references/report-types/sb/sbPromptAdExtension.md (4170b), references/report-types/sb/sbPurchasedProduct.md (2262b), references/report-types/sb/sbSearchTerm.md (3788b), references/report-types/sb/sbTargeting.md (4330b), references/report-types/sd/index.md (426b), references/report-types/sd/sdAdGroup.md (3664b), references/report-types/sd/sdAdvertisedProduct.md (3473b), references/report-types/sd/sdCampaigns.md (3878b), references/report-types/sd/sdGrossAndInvalids.md (2544b), references/report-types/sd/sdPurchasedProduct.md (2742b), references/report-types/sd/sdTargeting.md (4672b), references/report-types/sp/index.md (494b), references/report-types/sp/spAdvertisedProduct.md (2794b), references/report-types/sp/spCampaigns.md (6362b), references/report-types/sp/spGrossAndInvalids.md (2747b), references/report-types/sp/spPromptAdExtension.md (3887b), references/report-types/sp/spPurchasedProduct.md (2869b), references/report-types/sp/spSearchTerm.md (4766b), references/report-types/sp/spTargeting.md (5365b), scripts/check_auth_dependency.py (6741b), scripts/get_report.py (26755b), skill-card.md (2694b), SKILL.md (12424b), _meta.json (144b)\n\nArchive v0.0.1: 24 files, 49437 bytes\n\nFiles: references/api.md (10603b), references/report-types/index.md (538b), references/report-types/sb/index.md (562b), references/report-types/sb/sbAdGroup.md (4001b), references/report-types/sb/sbAds.md (3314b), references/report-types/sb/sbCampaignPlacement.md (3673b), references/report-types/sb/sbCampaigns.md (4286b), references/report-types/sb/sbGrossAndInvalids.md (1786b), references/report-types/sb/sbPromptAdExtension.md (4170b), references/report-types/sb/sbPurchasedProduct.md (2262b), references/report-types/sb/sbSearchTerm.md (3788b), references/report-types/sb/sbTargeting.md (4330b), references/report-types/sp/index.md (494b), references/report-types/sp/spAdvertisedProduct.md (2794b), references/report-types/sp/spCampaigns.md (6362b), references/report-types/sp/spGrossAndInvalids.md (2747b), references/report-types/sp/spPromptAdExtension.md (3887b), references/report-types/sp/spPurchasedProduct.md (2869b), references/report-types/sp/spSearchTerm.md (4766b), references/report-types/sp/spTargeting.md (5365b), scripts/check_auth_dependency.py (6741b), scripts/get_report.py (26755b), SKILL.md (12028b), _meta.json (144b)","readmeExcerpt":"Skill: 亚马逊-广告报表 Owner: linkfox-ai Summary: 亚马逊广告（Amazon Ads）报告一站式获取技能，覆盖 Sponsored Products (SP) / Sponsored Brands (SB) / Sponsored Display (SD) 全部报告类型。脚本自动完成报告的创建、等待、下载和解压，直接返回可读的结构化数据。真实可用的报告类型及每类的列清单/groupBy/filters 以 references/report-types/{adProduct-dir}/{reportTypeId}.md 为单一真相源。当用户提到拉取亚马逊广告报告、下载 Amazon Ads 报告、获取 SP/SB/SD 广告活动/关键词/搜索词/投放商品/购买商品/广告组/流量异常/Prompt 扩展等任意报告时触发。本技能依赖 linkfox-amazon-ads-auth。Sponsored","codeSnippets":[],"executableExamples":[{"language":"bash","snippet":"python scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"adProduct\": \"SPONSORED_PRODUCTS\",\n  \"groupBy\": [\"campaign\"],\n  \"columns\": [\"date\",\"campaignId\",\"campaignName\",\"impressions\",\"clicks\",\"cost\"],\n  \"startDate\": \"2026-04-27\",\"endDate\": \"2026-05-03\",\n  \"timeUnit\": \"DAILY\"\n}'"},{"language":"bash","snippet":"python scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"spSearchTerm\",\n  \"adProduct\": \"SPONSORED_PRODUCTS\",\n  \"groupBy\": [\"searchTerm\"],\n  \"columns\": [\"searchTerm\",\"keyword\",\"matchType\",\"impressions\",\"clicks\",\"cost\",\n              \"sales7d\",\"sales14d\",\"purchases7d\",\"acosClicks14d\",\"roasClicks14d\",\n              \"startDate\",\"endDate\"],\n  \"startDate\": \"2026-04-01\",\"endDate\": \"2026-04-30\",\n  \"timeUnit\": \"SUMMARY\",\n  \"filters\": [{\"field\":\"keywordType\",\"values\":[\"BROAD\",\"PHRASE\",\"EXACT\"]}]\n}'"},{"language":"bash","snippet":"python scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"sbAdGroup\",\n  \"adProduct\": \"SPONSORED_BRANDS\",\n  \"groupBy\": [\"adGroup\"],\n  \"columns\": [\"adGroupId\",\"adGroupName\",\"impressions\",\"clicks\",\"cost\",\"purchases\",\"sales\",\"startDate\",\"endDate\"],\n  \"startDate\": \"2026-04-01\",\"endDate\": \"2026-04-30\"\n}'"},{"language":"bash","snippet":"python scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportTypeId\": \"sdCampaigns\",\n  \"adProduct\": \"SPONSORED_DISPLAY\",\n  \"groupBy\": [\"campaign\"],\n  \"columns\": [\"date\",\"campaignId\",\"campaignName\",\"impressions\",\"clicks\",\"cost\",\"purchases\",\"sales\"],\n  \"startDate\": \"2026-04-27\",\"endDate\": \"2026-05-03\",\n  \"timeUnit\": \"DAILY\"\n}'"},{"language":"bash","snippet":"python scripts/get_report.py '{\n  \"profileId\": 1234567890, \"region\": \"NA\",\n  \"reportId\": \"7df1ef5d-45ba-40cc-b607-ff2148cf4f5e\",\n  \"maxAttempts\": 60, \"pollInterval\": 30\n}'"},{"language":"json","snippet":"{\n  \"success\": true,\n  \"reportId\": \"4ee811a0-...\",\n  \"reportTypeId\": \"spCampaigns\",\n  \"startDate\": \"2026-04-28\", \"endDate\": \"2026-05-04\",\n  \"downloadPath\": \"C:/.../tmp/report_data.json\",\n  \"extractedFileHttpUrl\": \"http://127.0.0.1:51234/download\",\n  \"extractedFileHttpServeSeconds\": 300\n}"}],"parameters":null,"dependencies":[],"permissions":[],"extractedFiles":[{"path":"SKILL.md","content":"---\nname: linkfox-amazon-ads-report\ndescription: 亚马逊广告（Amazon Ads）报告一站式获取技能，覆盖 Sponsored Products (SP) / Sponsored Brands (SB) / Sponsored Display (SD) 全部报告类型。脚本自动完成报告的创建、等待、下载和解压，直接返回可读的结构化数据。真实可用的报告类型及每类的列清单/groupBy/filters 以 `references/report-types/{adProduct-dir}/{reportTypeId}.md` 为单一真相源。当用户提到拉取亚马逊广告报告、下载 Amazon Ads 报告、获取 SP/SB/SD 广告活动/关键词/搜索词/投放商品/购买商品/广告组/流量异常/Prompt 扩展等任意报告时触发。本技能依赖 linkfox-amazon-ads-auth。Sponsored Television (ST) / Amazon DSP 暂未覆盖。\n---\n\n# Amazon Ads 报告获取\n\n报告一站式获取：脚本经 `developerProxy` 传 `profileId`（服务端解析 token），自动完成报告的创建、等待（约 2–10 分钟）、下载和解压，直接返回可读的结构化数据。\n脚本本身不做\"该选哪些列 / 该怎么分组\"的业务判断，这些由 agent 先查 `references/report-types/` 下对应的 `.md` 文件，再显式传给脚本。\n\n**依赖 `linkfox-amazon-ads-auth`**（脚本启动自动检查；未安装时 exit 42，stderr 打 `DEPENDENCY_MISSING`）。\n\n### ⚠️ 多账号场景：调用前必须解析好 profileId\n\n用户经常只说自然语言（\"美国站\"、\"日本站\"、\"我的店铺\"），本 skill 的所有脚本都必须拿到数字 `profileId` 才能调。按下列顺序处理，**不要跳过**：\n\n1. 先调 `linkfox-amazon-ads-auth` 的 `authorized_stores.py` 拉出用户已授权的账号 × 站点清单。\n2. 根据用户提到的站点（映射到 `countryCode`，如 美国→`US`）匹配候选 profile：\n   - **只有 1 个候选** → 静默取对应 profileId，继续调用；不要把 profileId 数字播报给用户。\n   - **≥ 2 个候选（同站点下多个授权账号）** → **必须向用户澄清**，用 `accountName` 问：\"你在美国站授权了 A 和 B 两个账号，这次用哪个？\"\n   - **0 个候选** → 告知用户该站点未授权，引导去 `linkfox-amazon-ads-auth` 做授权。\n3. **严禁**让用户直接报 profileId 数字。\n4. **严禁**在歧义下\"挑第一个\"或\"选默认\"绕过澄清。\n\n完整决策表见 `linkfox-amazon-ads-auth` SKILL.md 的 **Usage Scenarios 第 4 节**。\n\n## 调用方式\n\n- **API 端点**：`POST /amazonAds/developerProxy`（不同操作通过请求体区分；完整参数/响应/错误码见 `references/api.md`）\n- **Python 脚本**：`python scripts/<脚本名>.py '<JSON 参数>' [--inline]`（可用脚本见上文脚本一览）\n- **成本约束**：本工具会消耗算力；失败/空结果不得自动换关键词、翻页或连续试探；需要继续检索时先向用户说明会产生额外消耗。\n\n**输出策略（脚本默认行为）**：\n- **始终**将完整响应写入 `<cwd>/linkfox/<YYYY-MM-DD>/<session>/data/<skill-name>-<timestamp>.json`（`<cwd>` 为脚本执行时的工作目录，在 Claude Code 里即当前项目目录；`<session>` 取自环境变量 `SESSION_ID`，按用户任务自动聚合；**禁止写入 /tmp**，当前目录不可写则报错）\n- 响应体 ≤ 8 KB：落盘后把完整 JSON 打印到 stdout\n- 响应体 > 8 KB：落盘后 stdout 只输出摘要（顶层字段、常见计数如 `total`/`costToken`、最大列表字段的长度 + 前 3 条样本）\n- 加 `--inline` 强制全量打印到 stdout（同样落盘）\n\n**读数据建议**：先看摘要判断是否足够；需要具体字段时优先用 `jq`或`ConvertFrom-Json`或`ConvertFrom-Json` 从保存的 json 文件按需抽取，避免整份 JSON 进入上下文。\n\n## 解决认证和算力问题\n发生以下异常情况时，采用 references/onboarding.md 引导解决问题：\n\n### 异常情况\n- **未配置API Key**：环境变量未配置 `LINKFOX_AGENT_API_KEY`，也未配置 `LINKFOXAGENT_API_KEY`。\n- **响应401或402状态码**\n- **响应提示算力或余额不足**：消息含\"算力余额不足/计费不足/余额不足/quota exceeded/insufficient balance/套餐到期/需充值/请充值\"，或类似含义的内容。\n\n## Core Concepts\n\n- **覆盖**：SP / SB / SD 全部报告类型（以 `references/report-types/` 下存在的 `.md` 为准；ST / DSP 暂未覆盖）\n- **一站式**：脚本内部自动完成报告创建 → 等待生成（约 2–10 分钟）→ 下载 → 解压，调用方只需等最终结果\n- **单脚本**：`get_report.py`（覆盖 SP / SB 全部 adProduct）\n- **元数据 vs. 运行参数**：\n  - 每个报告类型的**可用字段**（timeUnit / groupBy / filters / 全部列名）集中在 `references/report-types/<adProduct-dir>/<reportTypeId>.md`\n  - **脚本运行参数**（等待间隔、访问链接时效等）见本文件和 `references/api.md`\n\n## 可用脚本\n\n| 脚本 | 职责 |\n|------|------|\n| `get_report.py` ⭐ | 一站式执行。**必填** `adProduct` / `groupBy` / `columns`，由 agent 从 report-types/ 提取后传入 |\n| `check_auth_dependency.py` | 检测 linkfox-amazon-ads-auth 是否安装 |\n\n完整脚本参数、响应结构见 `refe"},{"path":"_meta.json","content":"{\n  \"ownerId\": \"kn7dmc1t4j28hem1twwyav85p182pb1j\",\n  \"slug\": \"linkfox-amazon-ads-report\",\n  \"version\": \"1.0.8\",\n  \"publishedAt\": 1789361654458\n}"},{"path":"references/api.md","content":"# linkfox-amazon-ads-report — 参数与字段参考\n\nAmazon Ads 报告自动化获取（SP / SB 覆盖；SD / ST / DSP 暂未覆盖）。授权见 `linkfox-amazon-ads-auth`；广告管理见 `linkfox-amazon-ads-manager`。\n\n> **📌 报告类型的真相源**：每个 `reportTypeId` 的完整规格（可用 columns / groupBy / filters / timeUnit / 日期约束 / 官方示例）在 `references/report-types/<adProduct-dir>/<reportTypeId>.md`，**按 adProduct 分目录**：\n> - `report-types/sp/`（Sponsored Products）\n> - `report-types/sb/`（Sponsored Brands）\n>\n> 目录总览见 `report-types/index.md`。本文件仅给运行时脚本参数与通用规则。\n\n## 支持的报告类型\n\n完整列表见 `report-types/index.md` 及各 adProduct 子目录下的 `index.md`。常用快速索引：\n\n| reportTypeId | 业务含义 | 文件 |\n|--------------|---------|------|\n| `spCampaigns` | 广告活动级（SP） | `report-types/sp/spCampaigns.md` |\n| `spAdvertisedProduct` | 投放商品级（SP） | `report-types/sp/spAdvertisedProduct.md` |\n| `spSearchTerm` | 搜索词级（SP） | `report-types/sp/spSearchTerm.md` |\n| `spTargeting` | 定向/关键词级（SP） | `report-types/sp/spTargeting.md` |\n| `sbCampaigns` / `sbAdGroup` / `sbAds` / ... | Sponsored Brands | `report-types/sb/*.md` |\n\n## 输入参数\n\n脚本支持两种模式：\n\n- **全链路模式（默认）**：创建报告 → 轮询 → 下载。需要下表全部必填字段。\n- **仅轮询模式**：入参中显式传入 `reportId`（见下方\"可选流程参数\"），跳过创建，只需 `profileId` / `region`，其余全部可省略。用于救回上次客户端超时但报告仍在跑的场景。\n\n### 必填（全链路模式）\n\n| 参数 | 类型 | 说明 |\n|------|------|------|\n| `profileId` | number | 从 ads-auth 获取 |\n| `region` | string | `NA` / `EU` / `FE` |\n| `reportTypeId` | string | 见 `report-types/index.md` 各 adProduct 子目录下的完整列表 |\n| `adProduct` | string | 取自对应 `.md` 文件的 frontmatter（`SPONSORED_PRODUCTS` / `SPONSORED_BRANDS`）|\n| `groupBy` | list | 取自对应 `.md` 文件的 frontmatter |\n| `columns` | list | 取自对应 `.md` 文件 Base metrics 表的子集 |\n| `startDate` | string | `YYYY-MM-DD`（含当天） |\n| `endDate` | string | `YYYY-MM-DD`（含当天） |\n\n### 可选业务参数\n\n| 参数 | 默认 | 说明 |\n|------|------|------|\n| `name` | `{reportTypeId}_{startDate}_{endDate}` | 报告显示名 |\n| `timeUnit` | `SUMMARY` | `DAILY`（每天一行） / `SUMMARY`（整期一行） |\n| `format` | `GZIP_JSON` | 响应文件格式 |\n| `filters` | 空 | 过滤条件数组，字段与取值见对应 `.md` 文件 |\n\n### 可选流程参数\n\n| 参数 | 默认 | 说明 |\n|------|------|------|\n| `reportId` | 无 | 若显式传入，脚本进入**仅轮询模式**：跳过创建步骤，直接对该 reportId 轮询与下载。此时只要 `profileId` / `region` + `reportId`，其他字段可省 |\n| `pollInterval` | 30 | 轮询间隔秒 |\n| `maxAttempts` | 15 | 最大轮询次数（默认约 7.5 分钟上限） |\n| `skipDepCheck` | false | 跳过依赖检查 |\n| `serveExtractedFileHttp` | true | 是否启本机 HTTP 服务 |\n| `serveHost` | `127.0.0.1` | 绑定地址（仅本机可访问） |\n| `servePort` | 0 | 端口（0=系统分配） |\n| `serveSeconds` | 300 | HTTP 服务存活秒 |\n| `includeAmazonSourceUrl` | false | 响应中带预签名 URL |\n\n## 日期限制\n\n- **跨度上限**：以对应 `.md` 文件 frontmatter 的 `dateRange.maxSpanDays` 为准（多数 31 天；`sbPurchasedProduct` 731 天；GrossAndInvalids 系列 365 天）。超出返回 HTTP 400 `\"must not exceed maximum range\"`。\n- **回溯上限**：以 `dateRange.dataRetentionDays` 为准（SP 多为 95 天，SB 60 天）。\n- **数据延迟**：~12 小时；`endDate >= 今天` 脚本会 stderr 警告但不拦截。建议 `endDate <= 昨天`。\n\n## 各报告类型的列\n\n每个 reportTypeId 的完整 Base metrics 列表、allowed groupBy、filters 枚举值，统一在 `report-types/<adProduct-dir>/<reportTypeId>.md` 中维护：\n\n- `.md` 的 **frontmatter** 提供 `adProduct` / `groupBy` / `timeUnit`（可选值）/ `format` / `filters` / `dateRange`\n- **Base "},{"path":"references/onboarding.md","content":"# 解决认证和算力问题\n\n调用本 skill 时若网关返回 **auth** 或 **billing** 错误，走本 skill 自带的 `scripts/onboarding.py` 完成引导。\n\n**auth 场景**：`errcode=401` 或消息含 `authorized error`/`鉴权失败`/`未授权`/`unauthorized`；或 `LINKFOX_AGENT_API_KEY` 与 `LINKFOXAGENT_API_KEY` 均为空。\n1. 若已配置 key → 先让用户重启会话（最常见误判），仍失败让用户重新取 key 或换手机号重注册\n2. 未配置 → 询问：自助去 https://agent.linkfox.com/ 取 key，或提供手机号让脚本注册\n3. 手机号路径：\n   - `python scripts/onboarding.py send-code <phone>` → 展示 JSON 里的 phone/agreements\n   - 收到验证码后：`python scripts/onboarding.py login <phone> <code>`\n   - 拿到 `api_key` 后把下面三平台配置转发给用户，提示重启会话生效：\n     - Windows PowerShell（永久）：`setx LINKFOX_AGENT_API_KEY \"<key>\"`\n     - macOS zsh：`echo 'export LINKFOX_AGENT_API_KEY=\"<key>\"' >> ~/.zshrc && source ~/.zshrc`\n     - Linux bash：`echo 'export LINKFOX_AGENT_API_KEY=\"<key>\"' >> ~/.bashrc && source ~/.bashrc`\n     - 变量名 `LINKFOX_AGENT_API_KEY`（主推）或 `LINKFOXAGENT_API_KEY`（老规范）任一即可\n\n**billing 场景**：`errcode=402` 或消息含 `算力/余额/quota/insufficient/充值/套餐到期`。\n- `python scripts/onboarding.py list-plans` → 有 AskUserQuestion 就弹菜单，否则输出编号清单让用户选\n- 校验 `plan_id` ∈ 清单、支付方式 ∈ 该套餐 `available_methods`（通常 `wechat/alipay`）\n- `python scripts/onboarding.py order <plan_id> <method>` → 展示优先级 PNG > `pay_url` > `ascii_qr`（标注兜底）\n- 已付款可选调 `python scripts/onboarding.py query <order_id>`，不主动轮询\n\n排除 `errcode=403`（无权限，不归入这两类）。所有子命令输出 stdout JSON，`error` 字段已含阶段前缀，透传给用户即可。完整用法：`python scripts/onboarding.py --help`。"},{"path":"references/report-types/index.md","content":"# Amazon Ads Report Types\n\n按 `adProduct` 分类。每个 `.md` 文件名即 `reportTypeId`，内容为官方原文 + YAML frontmatter 结构化字段，用于构造 `POST /reporting/reports` 请求体。\n\n## 目录\n\n| adProduct | 目录 |\n|-----------|------|\n| SPONSORED_PRODUCTS | [`sp/`](./sp/) |\n| SPONSORED_BRANDS | [`sb/`](./sb/) |\n| SPONSORED_DISPLAY | [`sd/`](./sd/) |\n\n> Sponsored Television (ST) / Amazon DSP 暂未覆盖，后续版本支持。\n\n## 数据源\n\nhttps://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types"}],"languages":[],"docsSourceLabel":"CLAWHUB","editorialOverview":"亚马逊广告（Amazon Ads）报告一站式获取技能，覆盖 Sponsored Products (SP) / Sponsored Brands (SB) / Sponsored Display (SD) 全部报告类型。脚本自动完成报告的创建、等待、下载和解压，直接返回可读的结构化数据。真实可用的报告类型及每类的列清单/groupBy/filters 以 `references/report-types/{adProduct-dir}/{reportTypeId}.md` 为单一真相源。当用户提到拉取亚马逊广告报告、下载 Amazon Ads 报告、获取 SP/SB/SD 广告活动/关键词/搜索词/投放商品/购买商品/广告组/流量异常/Prompt 扩展等任意报告时触发。本技能依赖 linkfox-amazon-ads-auth。Sponsored Television (ST) / Amazon DSP 暂未覆盖。 Skill: 亚马逊-广告报表 Owner: linkfox-ai Summary: 亚马逊广告（Amazon Ads）报告一站式获取技能，覆盖 Sponsored Products (SP) / Sponsored Brands (SB) / Sponsored Display (SD) 全部报告类型。脚本自动完成报告的创建、等待、下载和解压，直接返回可读的结构化数据。真实可用的报告类型及每类的列清单/groupBy/filters 以 references/report-types/{adProduct-dir}/{reportTypeId}.md 为单一真相源。当用户提到拉取亚马逊广告报告、下载 Amazon Ads 报告、获取 SP/SB/SD 广告活动/关键词/搜索词/投放商品/购买商品/广告组/流量异常/Prompt 扩展等任意报告时触发。本技能依赖 linkfox-amazon-ads-auth。Sponsored","editorialQuality":{"score":100,"threshold":65,"status":"ready","wordCount":993,"uniquenessScore":45,"reasons":[]}},"media":{"evidence":{"source":"no-media","verified":false,"confidence":"low","updatedAt":"2026-10-10T02:58:23.782Z","emptyReason":"No screenshots, media assets, or demo links are available."},"primaryImageUrl":null,"mediaAssetCount":0,"assets":[],"demoUrl":null},"ownerResources":{"evidence":{"source":"unclaimed","verified":false,"confidence":"low","updatedAt":"2026-10-10T02:58:23.782Z","emptyReason":"This page has not been claimed by the agent owner."},"hasCustomPage":false,"customPageUpdatedAt":null,"customLinks":[],"structuredLinks":{"docsUrl":null,"demoUrl":null,"supportUrl":null,"pricingUrl":null,"statusUrl":null},"customPage":null},"relatedAgents":{"evidence":{"source":"protocol-neighbors","verified":false,"confidence":"medium","updatedAt":"2026-10-10T05:39:55.755Z","emptyReason":null},"items":[{"id":"8ebccd8e-3863-4187-8355-c3f14e1f9edf","entityType":"agent","canonicalPath":"/agent/iofficeai-aionui","slug":"iofficeai-aionui","name":"AionUi","description":"Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!","url":"https://github.com/iOfficeAI/AionUi","homepage":"https://www.aionui.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-10-09T19:11:12.944Z","createdAt":"2026-02-25T03:38:16.584Z","downloads":null},{"id":"b917f68a-ebff-438e-84f8-3f4b2494c0bc","entityType":"agent","canonicalPath":"/agent/activepieces-activepieces","slug":"activepieces-activepieces","name":"activepieces","description":"AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents","url":"https://github.com/activepieces/activepieces","homepage":"https://www.activepieces.com","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-15T02:22:12.426Z","createdAt":"2026-02-25T03:38:12.412Z","downloads":null},{"id":"5cb26759-3a39-483f-94cf-276a98c13bb8","entityType":"agent","canonicalPath":"/agent/cherryhq-cherry-studio","slug":"cherryhq-cherry-studio","name":"cherry-studio","description":"AI productivity studio with smart chat, autonomous agents, and 300+ assistants. Unified access to frontier LLMs","url":"https://github.com/CherryHQ/cherry-studio","homepage":"https://cherry-ai.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-11T14:38:40.986Z","createdAt":"2026-02-25T03:38:19.379Z","downloads":null},{"id":"6f6582d0-5d76-4f0f-b81d-86520247950b","entityType":"agent","canonicalPath":"/agent/copilotkit-copilotkit","slug":"copilotkit-copilotkit","name":"CopilotKit","description":"The Frontend for Agents & Generative UI. React + Angular","url":"https://github.com/CopilotKit/CopilotKit","homepage":"https://docs.copilotkit.ai","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-03-25T09:50:57.846Z","createdAt":"2026-02-25T03:39:14.617Z","downloads":null}],"links":{"hub":"/agent","source":"/agent/source/clawhub","protocols":[{"label":"OpenClaw","href":"/agent/protocol/openclew"}]}}}