How Direct Webhooks Work
When you submit an async job with a direct webhook configured, Reducto will:- Process your document asynchronously
- Send an HTTP POST request to your webhook URL when the job completes (or fails)
- Include the job status, job ID, and any metadata you provided in the request body
Webhook Payload
The webhook notification will be sent as a JSON POST request with the following structure:Setting Up Your Webhook Endpoint
Your webhook endpoint should:- Accept HTTP POST requests
- Return a 2xx status code to acknowledge receipt
- Process the webhook payload to retrieve the job result
Submit Async Job with Direct Webhook
Webhook Handler
View webhook handler code (Python / TypeScript)
View webhook handler code (Python / TypeScript)
Using Direct Webhooks with Extract
Direct webhooks work with all async endpoints. Hereβs an example with the extract endpoint:Validating Webhook Requests
Since direct webhooks donβt include built-in request signing like Svix webhooks, itβs important to implement your own validation strategy to ensure webhook requests are legitimate. Here are several approaches you can use:Strategy 1: Secret Token in Metadata
Include a secret token in your webhook metadata and validate it on receipt. This is the simplest approach for basic validation.View code (Python / TypeScript)
View code (Python / TypeScript)
Strategy 2: Job ID Verification
Maintain a list of expected job IDs and only process webhooks for jobs youβve submitted. This prevents processing of forged webhook requests.View code (Python / TypeScript)
View code (Python / TypeScript)
Strategy 3: IP Allowlisting
Restrict webhook requests to come only from Reductoβs IP addresses. Contact Reducto support to get the current list of webhook source IPs for your deployment.View code (Python / TypeScript)
View code (Python / TypeScript)
Strategy 4: Combined Approach (Recommended)
For production systems, combine multiple validation strategies for defense in depth:View code (Python / TypeScript)
View code (Python / TypeScript)
Best Practices
- Secure Your Endpoint: Use HTTPS for your webhook URL to ensure secure transmission of data.
- Implement Validation: Always validate webhook requests using one or more of the strategies above. For production systems, use a combined approach.
- Handle Retries: Your endpoint should be idempotent, as Reducto will retry failed deliveries up to 3 times.
- Quick Response: Return a 2xx status code quickly. Process the job result asynchronously if needed to avoid timeouts.
- Use Metadata: Include custom metadata in your webhook configuration to help identify and route jobs in your application.
- Error Handling: Implement proper error handling in your webhook endpoint to avoid missing notifications.
- Monitor Webhook Failures: Log and monitor failed webhook validations to detect potential security issues or misconfigurations.
Comparison with Svix Webhooks
Direct webhooks are simpler to set up but have fewer features compared to Svix webhooks:| Feature | Direct Webhooks | Svix Webhooks |
|---|---|---|
| Setup complexity | Simple | Requires Svix configuration |
| Retry logic | Basic (3 retries) | Advanced with exponential backoff |
| Webhook signing | Not included | Included for security |
| Delivery tracking | Not included | Full delivery dashboard |
| Multiple endpoints | One URL per job | Multiple endpoints via channels |