Webhook
基础 URL https://arteza.ai/api/v1
OpenAPI 3.1 规范,用于 SDK 生成器和代理: /api/v1/openapi.json
官方 TypeScript 和 Python SDK、命令行工具和代理技能: SDK 和命令行工具
在创建生成时传递 webhook_url,当生成完成、失败或被取消时,我们会将最终生成 POST 到该 URL。该 URL 必须是公开的 HTTPS。
每次传递都使用您的 webhook 密钥和标准 Webhooks 方案进行签名:webhook-id、webhook-timestamp 和 webhook-signature 标头。在信任请求体之前验证签名,并使用 webhook-id 忽略重复项。
import crypto from "node:crypto";
// secret: whsec_... from the console. body: the raw request body string.
export function verify(secret, headers, body) {
const id = headers["webhook-id"];
const ts = headers["webhook-timestamp"];
if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
const expected = crypto.createHmac("sha256", key).update(`${id}.${ts}.${body}`).digest("base64");
return headers["webhook-signature"].split(" ").some((s) => {
const sig = s.split(",")[1] ?? "";
return sig.length === expected.length && crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected));
});
}在十秒内使用任何 2xx 状态码回复。否则我们将以指数退避重试 24 小时。您可以从控制台查看每次传递并重新发送。