Skip to Content
Webhooks & EventsWebhooks & Signatures

Webhooks & Signature Verification

When an agent is configured in webhook mode, msend sends an HTTP POST to your HTTPS URL for every event (message.received, message.status, conversation.created, channel.status).

Use Send test event in the UI (or POST /api/v1/agent/test_event) to send a ping event to your endpoint.

Request Format

POST https://your-agent.example.com/webhooks/msend Content-Type: application/json Msend-Event-Id: evt_01J... Msend-Timestamp: 1700000000 Msend-Signature: v1=<hex HMAC-SHA256 of "<timestamp>.<raw body>"> { "id": "evt_01J...", "kind": "ping", "created_at": "2026-01-01T00:00:00Z", "data": {} }

Verifying the Signature

Always verify against the raw request bytes (never re-serialized JSON), compare in constant time, and reject timestamps older than 5 minutes (300 seconds) to prevent replay attacks.

import hashlib, hmac, time def valid(secret: str, raw_body: bytes, timestamp: str, signature: str) -> bool: try: if abs(time.time() - int(timestamp)) > 300: return False except ValueError: return False expected = "v1=" + hmac.new( secret.encode(), timestamp.encode() + b"." + raw_body, hashlib.sha256, ).hexdigest() return hmac.compare_digest(expected, signature)

Retries, Deduplication & Replay

  • Respond fast: Return any 2xx status within 10 seconds, and run LLM inference asynchronously.
  • Retries: Non-2xx responses (including redirects, which are not followed) are retried at ~10s, 1m, 5m, 30m, 2h, 6h, and 12h. The 8th failure marks the delivery dead.
  • Inspect & Replay: List deliveries via GET /api/v1/webhook_deliveries?status= and re-queue any delivery with POST /api/v1/webhook_deliveries/:id/replay.
  • Deduplicate: Events may be delivered more than once; deduplicate on Msend-Event-Id.

SSRF Protection: By default, msend requires https:// URLs and blocks loopback, private-range, link-local, and cloud-metadata IP targets on every delivery. For local development only, set ALLOW_INSECURE_WEBHOOKS=true and ALLOW_PRIVATE_WEBHOOK_TARGETS=true.

Last updated on