Webhook Integration Guide

Webhooks let external services trigger your agents automatically. When a webhook fires, it sends your payload to the agent for processing.

Inbound: Trigger an Agent

Send a POST request with your API key and any JSON payload:

curl -X POST "https://automatedworx.com/api/webhooks.php?trigger=AGENT_ID" \
  -H "X-API-Key: aw_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"event": "form_submitted", "data": {"name": "John", "email": "john@example.com"}}'

Outbound: Receive Results

Configure a webhook URL on your agent to receive results after each execution. We'll send a POST with HMAC-SHA256 signature verification:

{
  "agent_id": 42,
  "status": "completed",
  "output": "Agent response text...",
  "tokens_used": 150,
  "triggered_at": "2025-01-15T09:00:00Z"
}

// Verify signature:
// X-Webhook-Signature: sha256=HMAC(body, your_webhook_secret)

Signature Verification (Node.js)

const crypto = require('crypto');
const expectedSig = 'sha256=' + crypto
  .createHmac('sha256', process.env.WEBHOOK_SECRET)
  .update(rawBody)
  .digest('hex');
if (crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expectedSig))) {
  // Valid — process the webhook
}