Retry Policy: Up to 5 attempts with 30-second intervalsBackoff Strategy: Linear backoff between retriesFailure Handling: After 5 failed attempts, the webhook is marked as failed
Timeout Handling
Request Timeout: 30 seconds per webhook requestConnection Timeout: 10 seconds to establish connectionBest Practice: Respond quickly with a 200 status code, process asynchronously
Security
HTTPS Required: All webhook URLs must use HTTPSIP Allowlist: Consider restricting access to RunBlob’s IP rangesValidation: Always validate the generation_id in your webhook handler
Keep track of generation IDs in your database to prevent duplicate processing:
Copy
def handle_webhook(data): generation_id = data['generation_id'] # Check if already processed if db.is_processed(generation_id): return # Skip duplicate # Mark as processed db.mark_processed(generation_id) # Process the video process_video(data)
Validate Payloads
Always validate webhook payloads before processing:
Copy
function validateWebhook(payload) { if (!payload.generation_id || !payload.status) { throw new Error('Invalid webhook payload'); } if (payload.status === 'completed' && !payload.video_url) { throw new Error('Missing video_url for completed generation'); } return true;}
Important: Always return a 200 status code quickly to acknowledge receipt. Perform heavy processing asynchronously to avoid timeouts.