public_api:webhooks:manage scope.
Register a webhook
Response (201)
GET /api/agents/crm/lead-webhooks (list; secrets never returned), PATCH /api/agents/crm/lead-webhooks/{id} (update; rotate_secret: true mints a new secret), and DELETE /api/agents/crm/lead-webhooks/{id}.
Event payload
Each delivery is a JSONPOST with this body:
Delivery headers
Verify the signature
ComputeHMAC_SHA256(secret, timestamp + "." + rawRequestBody) and compare (constant-time) to the hex in X-Mega-Signature. Verify against the raw request body bytes — do not re-serialize the parsed JSON.
Replay protection
X-Mega-Timestamp is part of the signed material. Reject deliveries whose timestamp is outside a tolerance window (~5 minutes is recommended, as shown above) so a captured payload can’t be replayed later.
Retries & delivery semantics
- Respond with a 2xx to acknowledge. Any non-2xx (or a timeout) is retried.
- Default timeout is 10s and MEGA makes up to retry_attempts + 1 attempts (default
retry_attempts: 5, i.e. up to 6 total), with exponential backoff capped at 30s. Both are configurable per webhook (timeout_seconds1–60,retry_attempts0–10). - Redirects are not followed and SSRF-blocked URLs are terminal — neither is retried.
- Delivery is at-least-once: the same event may arrive more than once. De-duplicate on
X-Mega-Delivery. - Only
lead.createdis emitted today, and only on a genuine new-lead insert (not on merges into an existing lead). Bulk-uploaded leads do not fire the webhook.