Skip to content

Webhooks

Webhooks send real-time HTTP POST requests to your server when events occur in EmacronAI CRM — leads, deals, email activity, form submissions, completed tasks, and WhatsApp template status changes.

Important: Always verify the X-Webhook-Signature header to confirm events are from EmacronAI CRM and not a third party.

Setup

  1. 1

    Create an endpoint

    Add a POST endpoint to your server that accepts JSON. It must respond with HTTP 200 within 10 seconds.

  2. 2

    Register in dashboard

    Go to Settings → Webhooks → + Add Webhook. Paste your URL and select the events you want to receive.

  3. 3

    Copy your signing secret

    EmacronAI CRM generates a signing secret per endpoint. Save it as an environment variable — never commit it to source code.

  4. 4

    Verify signatures

    Validate each incoming webhook using HMAC-SHA256. See signature verification section below.

Signature verification

Every webhook request includes an X-Webhook-Signature header with the value sha256=<hex> — an HMAC-SHA256 of the raw request body (the exact bytes, before JSON parsing) keyed with your endpoint's signing secret. Related headers: X-Webhook-Event (event name), X-Webhook-Id (endpoint id), X-Webhook-Timestamp (ISO 8601). Compare with a constant-time function and reject missing or malformed values.

Node.js (Express)
const crypto = require('crypto');

app.post('/webhook', express.raw({ type: 'application/json' }), (req, res) => {
  const raw = req.headers['x-webhook-signature'];
  const secret    = process.env.WEBHOOK_SECRET;

  if (typeof raw !== 'string' || !raw.startsWith('sha256=')) {
    return res.status(401).send('Missing or malformed signature');
  }
  const received = raw.slice('sha256='.length);

  const expected = crypto
    .createHmac('sha256', secret)
    .update(req.body) // raw Buffer — express.raw(), not res.json()
    .digest('hex');

  // Constant-time compare: never use === on signatures.
  const a = Buffer.from(received, 'utf8');
  const b = Buffer.from(expected, 'utf8');
  if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) {
    return res.status(401).send('Invalid signature');
  }

  const event = JSON.parse(req.body);
  console.log('Event:', event.event, event.data);

  res.status(200).send('OK');
});
Python (Flask)
import hmac, hashlib, os
from flask import Flask, request, abort

app = Flask(__name__)

@app.route('/webhook', methods=['POST'])
def webhook():
    raw = request.headers.get('X-Webhook-Signature', '')
    if not raw.startswith('sha256='):
        abort(401)
    received = raw[len('sha256='):]
    secret    = os.environ['WEBHOOK_SECRET'].encode()
    body      = request.get_data()  # raw bytes, before JSON parsing

    expected = hmac.new(secret, body, hashlib.sha256).hexdigest()
    if not hmac.compare_digest(received, expected):
        abort(401)

    event = request.get_json()
    print(f"Event: {event['event']}", event['data'])
    return 'OK', 200

These are outbound EmacronAI CRM event signatures. They are separate from signatures you may receive directly from third parties (Meta, payment providers, email providers) on their own endpoints — verify each against the provider's documented scheme.

Event reference

lead.created

Description

Fired when a new lead is discovered or created in the workspace.

Example payload

{
  "event": "lead.created",
  "workspace_id": "3f2b6c1e-...",
  "timestamp": "2026-11-26T10:15:30.000Z",
  "data": {
    "lead_id": "8c1d4a7f-...",
    "activity_type": "lead_discovered"
  }
}
lead.stage_changed

Description

Fired when a lead moves to a different pipeline stage.

Example payload

{
  "event": "lead.stage_changed",
  "workspace_id": "3f2b6c1e-...",
  "timestamp": "2026-11-26T10:18:00.000Z",
  "data": {
    "lead_id": "8c1d4a7f-...",
    "activity_type": "stage_changed"
  }
}
deal.created

Description

Fired when a deal is created in the workspace.

Example payload

{
  "event": "deal.created",
  "workspace_id": "3f2b6c1e-...",
  "timestamp": "2026-11-26T10:20:00.000Z",
  "data": {
    "lead_id": "8c1d4a7f-...",
    "activity_type": "deal_created"
  }
}
deal.won

Description

Fired when a deal is marked won.

Example payload

{
  "event": "deal.won",
  "workspace_id": "3f2b6c1e-...",
  "timestamp": "2026-11-26T10:25:00.000Z",
  "data": {
    "lead_id": "8c1d4a7f-...",
    "activity_type": "deal_won"
  }
}
deal.lost

Description

Fired when a deal is marked lost.

Example payload

{
  "event": "deal.lost",
  "workspace_id": "3f2b6c1e-...",
  "timestamp": "2026-11-26T10:26:00.000Z",
  "data": {
    "lead_id": "8c1d4a7f-...",
    "activity_type": "deal_lost"
  }
}
email.sent

Description

Fired when an outreach email is sent.

Example payload

{
  "event": "email.sent",
  "workspace_id": "3f2b6c1e-...",
  "timestamp": "2026-11-26T10:30:00.000Z",
  "data": {
    "lead_id": "8c1d4a7f-...",
    "activity_type": "email_sent"
  }
}
email.replied

Description

Fired when a contact replies to an outreach email.

Example payload

{
  "event": "email.replied",
  "workspace_id": "3f2b6c1e-...",
  "timestamp": "2026-11-26T11:02:00.000Z",
  "data": {
    "lead_id": "8c1d4a7f-...",
    "activity_type": "email_replied"
  }
}
form.submitted

Description

Fired when a published form receives a submission.

Example payload

{
  "event": "form.submitted",
  "workspace_id": "3f2b6c1e-...",
  "timestamp": "2026-11-26T11:10:00.000Z",
  "data": {
    "lead_id": "8c1d4a7f-...",
    "activity_type": "form_submitted"
  }
}
task.completed

Description

Fired when a lead task is completed.

Example payload

{
  "event": "task.completed",
  "workspace_id": "3f2b6c1e-...",
  "timestamp": "2026-11-26T11:15:00.000Z",
  "data": {
    "lead_id": "8c1d4a7f-...",
    "activity_type": "task_completed"
  }
}
template.status_changed

Description

Fired when Meta approves, rejects, pauses, or otherwise changes a WhatsApp template.

Example payload

{
  "event": "template.status_changed",
  "workspace_id": "3f2b6c1e-...",
  "timestamp": "2026-11-26T11:20:00.000Z",
  "data": {
    "template_name": "order_confirmation",
    "language": "en_US",
    "new_status": "APPROVED",
    "rejected_reason": null,
    "meta_template_id": "1234567890"
  }
}

Activity events also include that activity's detail fields inside data. The public API registration endpoint (POST /api/v1/webhooks) currently accepts template.status_changed and the reserved workspace.low_credits option; register the CRM activity events from Settings → Webhooks. The low-credit event is accepted by registration but is not currently emitted.

Retry policy

A delivery counts as failed if your endpoint returns a non-2xx status or does not respond within 10 seconds. After a failed delivery attempt, the next attempt waits 2^attempt × 30s, where attempt is the attempt that just failed (after attempt 1 → 60s, after attempt 2 → 120s, after attempt 3 → 240s). The number of attempts is configurable per endpoint (Max retries, default 3 — i.e. the initial delivery plus up to 2 retries; set 0 for no retries).

AttemptDelay after previous failure
1 (initial)Immediately when the event occurs
2 (first retry)60 seconds after attempt 1
3 (second retry)120 seconds after attempt 2
4 (third retry)240 seconds after attempt 3 — only when Max retries is 4 or more

Once an endpoint exceeds its configured attempts, that event is marked failed and is not retried — check the webhook delivery log in your dashboard. Independently of retries, an endpoint that fails 10 consecutive deliveries is auto-disabled and must be re-enabled manually after you have fixed the receiver.