Skip to content
On this page

Webhooks: leads into your CRM

Viralmaxing sends every lead of a workspace's funnels as a POST request to your address: who wrote the code word, under which reel, what they answered in the form, whether they qualified and whether they paid. A receiver takes about 10 minutes: one address per workspace, a JSON body, an HMAC-SHA256 signature and retries on failure.

1. Set the address

Open Settings → Integrations → «Leads» and press «Set the address». Paste the https:// address of your receiver and save: a signing secret like whsec_… appears. Keep it in your receiver's environment:

bash
export VIRALMAXING_WEBHOOK_SECRET='whsec_...'

There is one address per workspace: the leads of every funnel go there, and new funnels send leads right away. Need a separate CRM? Use a separate workspace.

2. Receive the request

Every event is a POST with an application/json body and three headers:

HeaderWhat it holds
X-Viralmaxing-Signaturet=<Unix seconds>,v1=<hex>: the signature, see step 3
X-Viralmaxing-Eventthe event: lead.created, lead.answered, lead.qualified, order.paid, order.refunded or test
X-Viralmaxing-Deliverythe delivery id; the same on every retry of the event

The body and every event with an example are on the Events page.

3. Verify the signature

v1 is HMAC-SHA256 of "<t>.<body>" under your secret, in hex. Take the body exactly as the bytes arrived, before parsing JSON. Drop requests whose t is older than 5 minutes: a captured request can't be replayed later, and a fresh timestamp won't match the signature.

Test vector: secret whsec_test, body {"event":"test"}, t=1700000000 give v1=21d2d3606ebbdbf9307ee15e83085df2b83c83dd87cc2e6d2ea6b1cb61afdc3c.

Node.js (Express)

js
import crypto from 'node:crypto';
import express from 'express';

const app = express();
const secret = process.env.VIRALMAXING_WEBHOOK_SECRET;

app.post('/viralmaxing', express.raw({ type: 'application/json' }), (req, res) => {
  const parts = Object.fromEntries(
    (req.get('X-Viralmaxing-Signature') ?? '').split(',').map((part) => part.split('=')),
  );

  if (!/^\d+$/.test(parts.t ?? '') || Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) {
    return res.sendStatus(400);
  }

  const expected = crypto.createHmac('sha256', secret).update(`${parts.t}.`).update(req.body).digest('hex');
  const given = Buffer.from(parts.v1 ?? '');
  if (given.length !== expected.length || !crypto.timingSafeEqual(given, Buffer.from(expected))) {
    return res.sendStatus(401);
  }

  const event = JSON.parse(req.body);
  // event.lead.id is the lead key, req.get('X-Viralmaxing-Delivery') the repeat key
  res.sendStatus(204);
});

Python (Flask)

python
import hashlib, hmac, json, os, time
from flask import Flask, abort, request

secret = os.environ["VIRALMAXING_WEBHOOK_SECRET"].encode()
app = Flask(__name__)

@app.post("/viralmaxing")
def viralmaxing():
    header = request.headers.get("X-Viralmaxing-Signature", "")
    parts = dict(part.split("=", 1) for part in header.split(",") if "=" in part)
    t = parts.get("t", "")
    if not t.isdigit() or abs(time.time() - int(t)) > 300:
        abort(400)
    body = request.get_data()
    expected = hmac.new(secret, t.encode() + b"." + body, hashlib.sha256).hexdigest()
    if not hmac.compare_digest(expected, parts.get("v1", "")):
        abort(401)
    event = json.loads(body)
    return "", 204

PHP

php
<?php
$secret = getenv('VIRALMAXING_WEBHOOK_SECRET');
$body = file_get_contents('php://input');
parse_str(str_replace(',', '&', $_SERVER['HTTP_X_VIRALMAXING_SIGNATURE'] ?? ''), $parts);
$t = $parts['t'] ?? '';
if (!ctype_digit($t) || abs(time() - (int) $t) > 300) { http_response_code(400); exit; }
$expected = hash_hmac('sha256', $t . '.' . $body, $secret);
if (!hash_equals($expected, $parts['v1'] ?? '')) { http_response_code(401); exit; }
$event = json_decode($body, true);
http_response_code(204);

4. Answer and don't double up

A 2xx answer is a delivery: answer fast and do the heavy work after answering. If your receiver didn't answer within 10 seconds, answered 5xx or 429, the event is retried in 1 minute, 10 minutes, 1 hour and 10 hours, five attempts in all. Other 4xx answers and redirects are not retried: we don't follow redirects, use the final address.

A retry carries the same X-Viralmaxing-Delivery and the same body with a new signature. Remember delivery ids and answer 2xx to one you've already handled. Private network addresses are refused: IPs from private ranges, names without a dot and the .local, .internal zones.

5. Check it

Press «Test» on the card: a test event with a sample lead goes out at once and its answer code shows next to the button. Below it is the log of the last 30 deliveries with the funnel, the answer code or reason and the number of attempts.

Build the receiver with an AI agent

Copy this into Claude, Cursor or Codex and add where the leads should go:

text
Build an HTTPS endpoint POST /viralmaxing that receives Viralmaxing webhooks.

- The body is JSON; read the raw bytes before parsing.

- The signature is in X-Viralmaxing-Signature: "t=<unix>,v1=<hex>". v1 = HMAC-SHA256(secret, "<t>.<raw body>") in hex.
  The secret is in VIRALMAXING_WEBHOOK_SECRET. Compare in constant time.
  Answer 400 if t is older than 300 seconds and 401 if the signature doesn't match.

- Test vector: secret whsec_test, t=1700000000, body {"event":"test"} →
  v1=21d2d3606ebbdbf9307ee15e83085df2b83c83dd87cc2e6d2ea6b1cb61afdc3c. Write a test for it.

- X-Viralmaxing-Delivery is the repeat key: acknowledge an id you've handled with 204 and don't handle it again.

- The event is in X-Viralmaxing-Event and the event field: lead.created, lead.answered, lead.qualified, order.paid, order.refunded, test.
  Join one person's events by lead.id. Form answers are lead.answers[] with field, type, question, answer.
  The funnel is automation.id and automation.name, the reel is reel.url.

- Answer 204 at once and write to the CRM after answering.

- The full contract: https://viralmaxing.com/developers/webhooks/events

Put the leads into: <your CRM, sheet or database>.

Read next