Skip to content

Webhooks API

Create and manage webhooks for external integrations.

List Webhooks

bash
GET /api/webhooks

Response

json
{
  "webhooks": [
    {
      "name": "github",
      "agent": "devops",
      "created_at": "2024-01-15T10:00:00Z",
      "last_triggered": "2024-01-15T12:00:00Z",
      "trigger_count": 42
    },
    {
      "name": "alerts",
      "agent": "ops",
      "created_at": "2024-01-15T11:00:00Z",
      "last_triggered": null,
      "trigger_count": 0
    }
  ]
}

Get Webhook

bash
GET /api/webhooks/:name

Response

json
{
  "name": "github",
  "agent": "devops",
  "secret": "***",
  "transform": {
    "message_template": "GitHub: {{event_type}} on {{repository}}"
  },
  "filters": {
    "include": ["push", "pull_request"]
  },
  "created_at": "2024-01-15T10:00:00Z",
  "last_triggered": "2024-01-15T12:00:00Z",
  "trigger_count": 42
}

Create Webhook

bash
POST /api/webhooks

Request

json
{
  "name": "github-webhook",
  "agent": "devops",
  "secret": "github-webhook-secret",
  "transform": {
    "message_template": "GitHub event: {{event_type}} from {{sender.login}}",
    "context_mapping": {
      "repository": "$.repository.full_name",
      "branch": "$.ref"
    }
  },
  "filters": {
    "include": ["push", "pull_request.opened"],
    "exclude": ["push.*.gh-pages"]
  },
  "response_mode": "async"
}

Parameters

FieldTypeRequiredDescription
namestringYesWebhook identifier
agentstringYesTarget agent
secretstringYesAuthentication secret
transformobjectNoMessage transformation config
filtersobjectNoEvent filtering rules
response_modestringNo"sync" or "async" (default: async)

Response

json
{
  "success": true,
  "webhook": {
    "name": "github-webhook",
    "url": "/api/webhooks/trigger/github-webhook",
    "created_at": "2024-01-15T12:00:00Z"
  }
}

Update Webhook

bash
PUT /api/webhooks/:name

Request

json
{
  "agent": "new-agent",
  "transform": {
    "message_template": "Updated template: {{event}}"
  }
}

Delete Webhook

bash
DELETE /api/webhooks/:name

Response

json
{
  "success": true,
  "message": "Webhook 'old-webhook' deleted"
}

Trigger Webhook

Generic Trigger

bash
POST /api/webhooks/:name/trigger

Request

json
{
  "payload": {
    "event_type": "push",
    "repository": "user/repo",
    "sender": {
      "login": "username"
    }
  }
}

Response (Async Mode)

json
{
  "success": true,
  "message": "Webhook triggered",
  "trigger_id": "trig_abc123"
}

Response (Sync Mode)

json
{
  "success": true,
  "agent_response": "I've processed the push event...",
  "processing_time_ms": 1500
}

Generic Webhook Endpoint

bash
POST /api/webhooks/generic

Send directly to an agent without creating a webhook.

Request

json
{
  "agent": "default",
  "message": "External event occurred",
  "context": {
    "source": "external_service",
    "event_id": "12345"
  },
  "secret": "your-webhook-secret"
}

Response

json
{
  "success": true,
  "response": "I've processed the event..."
}

Platform Webhooks

Telegram Webhook

bash
POST /api/webhooks/telegram

Receives Telegram Update objects.

Slack Webhook

bash
POST /api/webhooks/slack

Receives Slack event payloads.

Slack Interactive

bash
POST /api/webhooks/slack/interactive

Receives Slack interactive component callbacks.

Discord Webhook

bash
POST /api/webhooks/discord

Receives Discord interaction payloads.

Transform Configuration

Message Templates

Use Jinja2-style syntax:

json
{
  "transform": {
    "message_template": "Alert: {{alert_name}} ({{severity}}) on {{instance}}"
  }
}

Available in payload:

json
{
  "alert_name": "HighCPU",
  "severity": "critical",
  "instance": "server-1"
}

Result:

Alert: HighCPU (critical) on server-1

Context Mapping

Extract values using JSONPath:

json
{
  "transform": {
    "context_mapping": {
      "service": "$.labels.service",
      "region": "$.labels.region",
      "severity": "$.status"
    }
  }
}

Default Values

json
{
  "transform": {
    "message_template": "Event: {{event_type | default('unknown')}}"
  }
}

Filter Configuration

Include Patterns

Only process matching events:

json
{
  "filters": {
    "include": ["push", "pull_request.*", "issues.opened"]
  }
}

Exclude Patterns

Skip matching events:

json
{
  "filters": {
    "exclude": ["*.bot", "push.gh-pages"]
  }

Conditional Filters

json
{
  "filters": {
    "condition": "$.severity == 'critical'"
  }
}

Webhook Logs

Get Webhook Logs

bash
GET /api/webhooks/:name/logs

Response

json
{
  "logs": [
    {
      "timestamp": "2024-01-15T12:00:00Z",
      "trigger_id": "trig_abc123",
      "success": true,
      "processing_time_ms": 1500
    }
  ]
}

Security

HMAC Verification

For services that use HMAC signatures:

bash
POST /api/webhooks/:name/verify

Request

json
{
  "signature": "sha256=...",
  "payload": {...}
}

IP Whitelist

Configure allowed source IPs:

json
{
  "security": {
    "allowed_ips": ["192.168.1.0/24", "10.0.0.1"]
  }
}

Open source · Self-hosted · Data sovereign