Skip to main content
MEGA can POST a signed event to your endpoint whenever a new lead is created. Managing webhooks requires the public_api:webhooks:manage scope.

Register a webhook

Response (201)
The secret is returned exactly once, at creation (and again only when you rotate_secret). Store it securely — it’s the key you verify signatures with. The URL must be public HTTPS; internal/loopback URLs are rejected (SSRF protection).
Manage webhooks with 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 JSON POST with this body:

Delivery headers

Verify the signature

Compute HMAC_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_seconds 1–60, retry_attempts 0–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.created is 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.