Skip to content

Webhook

Send alerts to any HTTP endpoint. Use this to integrate with PagerDuty, Opsgenie, custom dashboards, or any service that accepts POST requests.

Adding a webhook channel

wnp notify add-channel <check-id> \
  --type webhook \
  --config url=https://your-service.example.com/alerts
curl -X POST https://api.wanepia.com/v1/checks/{check_id}/policy/channels \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel_type": "webhook",
    "config": {
      "url": "https://your-service.example.com/alerts",
      "secret": "optional-hmac-secret"
    }
  }'

Config fields

Key Required Description
url Yes HTTPS endpoint to POST to
secret No If set, Wanepia signs the body with HMAC-SHA256 and adds X-Wanepia-Signature header

Payload format

{
  "entity_id": "...",
  "entity_name": "payments-api",
  "check_id": "...",
  "tenant_id": "...",
  "from_state": "up",
  "to_state": "down",
  "transition_id": "...",
  "timestamp": "2024-01-20T03:17:42Z"
}

HMAC signature verification

When a secret is configured, Wanepia adds:

X-Wanepia-Signature: sha256=<hex>

Verify it in your handler:

import hmac, hashlib

def verify(body: bytes, signature: str, secret: str) -> bool:
    expected = "sha256=" + hmac.new(
        secret.encode(), body, hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(expected, signature)
func verify(body []byte, sig, secret string) bool {
    mac := hmac.New(sha256.New, []byte(secret))
    mac.Write(body)
    expected := "sha256=" + hex.EncodeToString(mac.Sum(nil))
    return hmac.Equal([]byte(expected), []byte(sig))
}

Example integrations

PagerDuty Events v2

Set url to https://events.pagerduty.com/v2/enqueue and write a small proxy that maps the Wanepia payload to PagerDuty's schema.

Custom Slack (alternative)

If you need a custom Slack layout, point the webhook at your own service and call Slack's API from there.

Troubleshooting

  • Wanepia expects a 2xx response. Any other status counts as a failure and triggers the retry loop.
  • Request timeout is 10 seconds.
  • Use wnp notify logs to inspect failed attempts and error messages.