Skip to main content
Async execution with webhooks is designed for very long-running tasks (>30 minutes) that would otherwise timeout. The execution happens asynchronously, and results are delivered to your webhook endpoint when complete.

Overview

Async webhook execution is perfect for:
  • ML model training (30+ minutes)
  • Large dataset processing
  • Video encoding/processing
  • Long-running simulations
  • Any task that exceeds normal timeout limits
Async webhook execution returns immediately with an execution_id. The agent executes code in the background and POSTs results to your callback URL when complete.

Basic Usage

Start async execution with a webhook callback:

Webhook Callback

Your webhook endpoint will receive a POST request when execution completes:

Signature Verification

Verify webhook signatures for security:

Custom Headers

Include custom headers in webhook callbacks:

Complete Example

Here’s a complete example with ML model training:

Webhook Payload

The webhook payload structure:
Headers:
  • X-HopX-Signature: HMAC-SHA256 signature (if secret provided)
  • X-HopX-Timestamp: Unix timestamp
  • Custom headers from callback_headers

Best Practices

1

1. Always Verify Signatures

Use callback_signature_secret and verify signatures in your webhook handler to ensure requests are authentic.
2

2. Handle Timeouts

Set appropriate timeouts based on expected execution time. Default is 30 minutes, max is typically 1 hour.
3

3. Use Custom Headers

Include authentication tokens or identifiers in callback_headers for secure webhook processing.
4

4. Handle Both Success and Failure

Check the status field in webhook payloads to handle both successful completions and failures.
5

5. Store Execution IDs

Store execution_id when starting async execution to correlate webhook callbacks with your records.

Next Steps