Webhook 事件
OpenAPI 文档中的 decision.completed 事件——发送给 webhook 目的地的请求、其请求头、事件的每个字段以及 Dcision 期望的回答。
POST <your webhook URL>Dcision 会向每个触发的 webhook 目的地发送一个 decision.completed 事件。该事件是 OpenAPI 文档的一部分,无需认证即可在 https://api.dcision.io/openapi.json 的 webhooks → decision.completed 下获取。
请求头
| 请求头 | 必需 | 说明 |
|---|---|---|
Dcision-Signature | 是 | t=<unix seconds>,v1=<hex>——使用你的签名密钥对 <t>.<raw body> 计算的 HMAC-SHA256;轮换后的 24 小时内会有两个 v1 条目。参见验证签名。 |
Dcision-Delivery | 是 | 投递 ID dlv_…——每次尝试都相同。 |
Dcision-Attempt | 是 | 1 到 6。 |
Dcision-Event | 是 | decision.completed。 |
Content-Type | 是 | application/json。 |
User-Agent | 是 | Dcision-Destinations/1.0 (+https://docs.dcision.io/destinations)。 |
请求体
{
"id": "dlv_8kJx2mQp4LzN7vR1tY6w",
"type": "decision.completed",
"created": 1759658400,
"livemode": true,
"destination": "notify_sales",
"data": {
"decision": "lead-qualification",
"decision_id": "dec_3fKq9ZtW1mXcV7bN2pLa",
"version": 4,
"execution_id": "exec_8HsT2kQw9ZyR4vMn1cXe",
"result": { "purchase_intent": 0.9412, "priority": "high", "route": "sales" },
"confidence": { "purchase_intent": 0.8824, "priority": 0.69, "route": 0.85 },
"scores": { "priority": 2.81 },
"composites": { "lead_score": 0.8414 },
"action": "continue",
"action_reason": { "type": "default" },
"params": { "message": "We need pricing for 500 users and want to start next month.", "team": "inbound" }
}
}| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 投递 ID dlv_…,每次尝试都相同——据此去重。 |
type | string | decision.completed。请检查它:将来可能会增加更多事件类型。 |
created | integer | 决策运行的时间,以 Unix 秒表示。 |
livemode | boolean | 使用 test 密钥(dcs_test_…)的运行以及来自 Playground 的运行为 false。 |
destination | string | 发送该事件的目的地的键。 |
data.decision | string | 决策的 slug。 |
data.decision_id | string | 决策的 ID,dec_…。 |
data.version | integer 或 null | 作答的版本;来自 Playground 时为 null,因为它运行的是草稿。 |
data.execution_id | string | 运行的 ID,exec_…——即 API 响应中的 execution_id。 |
data.result | object | 按问题为键的回答。引擎错误 fallback 之后为空。 |
data.confidence | object | 每个回答的置信度,从 0 到 1。 |
data.scores | object | 每个评分题的加权级别;没有评分题时为 {}。 |
data.composites | object | 每个复合指标的值;没有复合指标时为 {}。 |
data.action | string | continue、block、escalate 或 fallback。 |
data.action_reason | object | 选择该行动的原因——参见 action_reason。 |
data.params | object | 在目的地中映射的参数。状态本身从不发送。 |
响应
| 你的回答 | Dcision 的处理 |
|---|---|
10 秒内返回任意 2xx | 投递成功。 |
408、425、429、5xx、超时或网络错误 | 重试——约七小时内尝试六次,在 429 和 503 上遵循 Retry-After。 |
任何其他 4xx,或重定向 | 投递立即失败;可以在应用中重新发送。 |
参见投递与重试。
其他目的地
API 请求、工作流和智能体带有相同的 Dcision-* 请求头和签名——对它们来说 Dcision-Event 也是 decision.completed——外加一个等于投递 ID 的 Idempotency-Key。它们的请求体不同:请使用不要求事件格式的 verifySignature / verify_signature 来验证它们。