Receiving Results
Handle asynchronous Data API outputs via webhooks.
SafetyKit sends object-level results through webhooks after processing completes. This gives you near real-time decisions without requiring your ingest path to block until analysis is finished.
Event type
Section titled “Event type”For object-level Data API completion, subscribe to workflow.succeeded.
{ "type": "workflow.succeeded", "namespace": "products", "id": "product_12345", "request_id": "req_01h2m7qdmdjckc30e1mnq6xqfd", "output": { "actions": [], "labels": [{ "label": "policy.example_violation" }], "fields": { "confidence": 0.92 } }}Handling pattern
Section titled “Handling pattern”When receiving webhook events:
- Verify webhook signatures.
- Filter by
typeandnamespace. - Use
idto map results to your records – this is the originalidprovided when the object was ingested. - Persist labels, fields and actions for downstream use.
If webhook delivery is delayed or temporarily unavailable, you can reconcile outputs with GET /v1/data/{namespace}/requests/{requestId}.
Minimal handler example
Section titled “Minimal handler example”if (event.type === "workflow.succeeded" && event.namespace === "products") { const { id, output } = event; await handleReviewDecision(id, output);}You can also subscribe to workflow.failed for failure lifecycle events, depending on how your workflow is configured.
See Webhooks Introduction and Verifying Signatures for setup and security guidance.