跳到主要内容

Webhook

当异步分析完成时,将发送包含分析结果的 webhook。为此,需要配置一个地址以接收更新通知,以及一个用于签署请求的 signature_key。如果尚未配置 webhook,请联系支持团队

签名

为确保 webhook 端点收到的请求来自我们的服务器,将随 webhook 一起发送 HMAC 签名。您可以使用此签名验证 webhook 确实来自我们的服务器。

Python 签名计算示例

    hmac_obj = hmac.new(signature_key.encode('utf-8'), (endpoint + method + payload).encode('utf-8'), hashlib.sha1)
return hmac_obj.hexdigest()

请求

请求具有以下格式,并通知分析已完成。请求使用 HTTP POST 方法,请求正文以 UTF-8 编码的文本发送。

成功 Webhook

curl --location 'YOUR-ENDPOINT-HERE' \
--header 'Signature: CALCULATED-HASH-HMAC' \
--data '{"id": "e314ffci-14f3-41a1-ad5d-c9c18782jhfe", "document": {"analysis_result": {...}, "validation_status": "valid"}, "status": "successful", "status_reason": "", "status_description": "Sucessfull Analysis"}'

错误 Webhook

curl --location 'YOUR-ENDPOINT-HERE' \
--header 'Signature: CALCULATED-HASH-HMAC' \
--data '{"id": "e314ffci-14f3-41a1-ad5d-c9c18782jhfe", "status": "bad_request", "status_reason": "missing_information
", "status_description": "The document is missing required information."}'