Skip to main content

Why webhooks for production

Webhooks are the recommended way to receive execution results in production. Instead of polling (which wastes API calls and is rate-limited), ModelRoute pushes results to your endpoint the moment they’re ready.
Start with polling, graduate to webhooks. Polling is perfect when you’re building your first integration and want to see results quickly. Once you’re ready for production, set up a webhook endpoint — it takes 10 minutes and gives you a dramatically better experience at scale.

Setup

1. Register a webhook endpoint

Save the secret immediately — it’s only shown once. You’ll need it to verify webhook signatures.

2. Create executions as normal

No changes to your execution requests. ModelRoute automatically delivers webhook events to all active endpoints subscribed to the relevant events.

3. Receive events

When an execution completes, ModelRoute sends a POST to your endpoint:

4. Verify the signature

Always verify the HMAC-SHA256 signature before processing. See webhook verification for code samples in Python, TypeScript, Go, and bash.

5. Respond with 200

Return a 200 OK to acknowledge receipt. If your endpoint returns a non-2xx status, ModelRoute retries with exponential backoff (up to 5 attempts over 24 hours).

Webhook events

Example: end-to-end flow

Retry policy

If your endpoint is unreachable or returns a non-2xx status: After 5 failed attempts (or 24 hours), the delivery is marked as failed. You can manually retry failed deliveries via the API.