Skip to main content

Webhooks

Webhooks notify your application when events occur in AgentGate. Instead of polling for status, receive push notifications when runs complete.

Why Use Webhooks

For production integrations, always use webhooks instead of polling.

Setting Up Webhooks

Create a Webhook

Response:
The webhook secret is only shown once at creation. Store it securely—you’ll need it for signature verification.

Endpoint Requirements

Your webhook endpoint must:
  • Use HTTPS (HTTP not allowed)
  • Be publicly accessible
  • Respond within 30 seconds
  • Return a 2xx status code for success

Event Types

Run Events

Verification Events

Common Subscriptions

Payload Format

All webhooks follow this structure:

run.completed Payload

run.failed Payload

Signature Verification

Always verify webhook signatures to ensure authenticity.

Signature Header

Webhooks include an X-AgentGate-Signature header:

Verification Process

1

Get Raw Body

Access the raw request body before JSON parsing.
2

Compute HMAC

Calculate HMAC-SHA256 of the body using your webhook secret.
3

Compare Signatures

Use constant-time comparison to match computed vs received signature.

Verification Code

Handling Webhooks

Best Practices

Return 200 immediately, then process asynchronously:
Handle duplicate deliveries gracefully using the event ID:
For reliability, queue webhooks for processing:

Retry Behavior

If your endpoint fails, AgentGate retries: After 5 failed attempts, the delivery is abandoned.

What Triggers Retries

  • HTTP 4xx responses (except 410)
  • HTTP 5xx responses
  • Connection timeouts
  • Connection refused

Avoiding Retries

  • Return 200/201/204 promptly
  • Return 410 if you want to stop retries
  • Ensure endpoint is accessible

Testing Webhooks

Test Endpoint

Send a test event to verify configuration:

Local Development

Use tunneling for local testing:
  1. Start a tunnel (ngrok, localtunnel, etc.)
  2. Create a webhook with your tunnel URL
  3. Submit a work order
  4. Receive webhook on localhost

Managing Webhooks

List Webhooks

Update Webhook

Delete Webhook

Tenant Context

Include tenant info in webhook payloads

API Reference

Webhooks API endpoints