Skip to main content

Webhooks

Structurify can send webhook notifications when events occur, allowing you to build automated workflows without polling.

Supported Events

EventDescription
extraction.completedExtraction job finished successfully
extraction.failedExtraction job failed
export.readyLarge export file is ready for download

Webhook Payload

All webhooks include a JSON payload:

{
"event": "extraction.completed",
"timestamp": "2026-01-02T10:30:00Z",
"data": {
"job_id": "job_abc123",
"project_id": "proj_xyz789",
"status": "done",
"total_tasks": 50,
"completed_tasks": 48,
"failed_tasks": 2
},
"signature": "sha256=..."
}

Verifying Signatures

Always verify webhook signatures to ensure requests are from Structurify.

from structurify.webhooks import verify_signature

def handle_webhook(request):
is_valid = verify_signature(
payload=request.body,
signature=request.headers['X-Structurify-Signature'],
secret='your_webhook_secret'
)

if not is_valid:
return {"error": "Invalid signature"}, 401

event = json.loads(request.body)
# Process event...

Best Practices

  1. Always verify signatures - Reject requests with invalid signatures
  2. Respond quickly - Return 200 within 5 seconds, process async
  3. Handle duplicates - Webhooks may be retried, use idempotency
  4. Use HTTPS - Only use secure endpoints for webhooks
  5. Log events - Keep audit logs of received webhooks

Retry Policy

Failed webhook deliveries are retried with exponential backoff:

AttemptDelay
1Immediate
21 minute
35 minutes
430 minutes
52 hours

After 5 failed attempts, the webhook is marked as failed.