Webhook
在 job 结束、店铺已连接或需要您处理、creator 在 WhatsApp 上回复或发送 Spark Ads code 时发送的签名 HTTP 通知。
用途: 在情况变化时(job 结束、店铺需要您处理、creator 回复)收到通知,而不是反复查询。
无需轮询,在 dashboard(Developer → Webhook)中添加一个 webhook endpoint:发生事件时,GrowSeller 会向您的 URL 发送 POST。您最多可以有 5 个 endpoint;每个 endpoint 自行选择其事件。
URL 必须是公开的 https:// 地址。签名 secret(whsec_…)在您添加 endpoint 时显示,之后只有在您生成新的 secret 时才会再次显示。
事件
只发送状态变化,绝不会为每个 creator 或每条已发送的消息发送一个事件:发给 10,000 个 creator 的 broadcast 在结束时只发送一个事件。
| 事件 | 何时发送 |
|---|---|
job.completed | 一个 job 已完成:broadcast、合作运行、同步或导入。data 带有其计数。 |
job.failed | 一个 job 因错误结束(data.error)。 |
job.stopped | 一个 job 被停止,由您或由套餐限制停止。 |
store.needs_reauth | 店铺必须重新登录;其 job 会等待。data:shop_id、name、platform。GET /workspace/shops 也会显示(needs_reauth、needs_reauth_at),直到店铺重新连接。 |
store.captcha_required | 店铺在等待 TikTok 安全验证;其 job 会等待。data:shop_id、name、platform。 |
whatsapp.message.received | creator 在 WhatsApp 上回复了。 |
spark_ads_code.received | creator 通过表单发送了 Spark Ads code。 |
store.connected | 店铺、电子邮件账号或 WhatsApp 号码已连接,或店铺已重新登录:来自 dashboard(TikTok Shop 通过 cookies 或电子邮件、Shopee、电子邮件、WhatsApp)、API 或连接链接。data 带有 platform(tiktok_shop、shopee、email、whatsapp)、id、reconnected,通过链接时还有 connect_link_id。 |
webhook.test 只由测试按钮发送。
请求
POST /hooks/growseller HTTP/1.1
Content-Type: application/json
User-Agent: GrowSeller-Webhooks/1.0
GrowSeller-Event: job.completed
GrowSeller-Delivery: 0193a7c2-…
GrowSeller-Signature: t=1763700000,v1=5d41402abc4b2a76b9719d911017c592…
{
"id": "7f1c…",
"type": "job.completed",
"created_at": "2026-11-21T09:00:00Z",
"data": {
"id": "…", "kind": "message_broadcast", "ref_id": "…", "shop_id": "…", "title": "November promo",
"status": "COMPLETED", "total": 1200, "done": 1200, "success": 1180, "failed": 20, "skipped": 0,
"error": null, "started_at": "…", "finished_at": "…"
}
}id 是事件的 id:重新发送的投递会保留它,因此可以用它忽略重复事件。店铺事件带有 shop_id、name 和 platform;whatsapp.message.received 带有账号、聊天、消息 id、类型、文本、发送者和时间;spark_ads_code.received 带有店铺、表单以及每个视频的 code。
验证签名
GrowSeller-Signature 的格式为 t=<unix seconds>,v1=<hex>,其中 v1 是以您 endpoint 的 secret 为密钥、对字符串 <t>.<raw body> 计算的 HMAC-SHA256。请基于收到的原始 body 原样计算,使用常量时间比较,并拒绝过旧的时间戳(例如超过五分钟)。
import { createHmac, timingSafeEqual } from 'node:crypto';
export function verify(rawBody: string, header: string, secret: string, toleranceSec = 300) {
const parts = Object.fromEntries(header.split(',').map((p) => p.split('=') as [string, string]));
const t = Number(parts.t);
if (!t || Math.abs(Date.now() / 1000 - t) > toleranceSec) return false;
const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex');
const given = Buffer.from(parts.v1 ?? '', 'hex');
const want = Buffer.from(expected, 'hex');
return given.length === want.length && timingSafeEqual(given, want);
}快速响应
在 5 秒内返回任意 2xx;耗时的工作在响应之后再做。5 秒内没有得到响应的投递会立即失败,并且不会重试。快速拒绝(错误状态码或端口关闭)会在 1、5、30、120、300、480 和 480 分钟后重试:大约一天内共 8 次尝试。不会跟随重定向。
连续 50 次投递失败后,endpoint 会被关闭;请在 dashboard 中重新开启。每个 endpoint 最近 7 天的投递都列在那里,并带有重新发送的按钮。