Skip to content

Replifier webhooks and signature verification

Outgoing webhooks notify your system when something happens in Replifier, without you having to poll the API. Every delivery is signed with a secret that only Replifier and you know: verify the signature before trusting the content, because anyone who knows your URL could send you fake data.

With an API key that has the webhooks.manage permission, or with the app session:

Terminal window
curl -X POST "https://api.replifier.com/v1/brands/$BRAND_ID/webhooks" \
-H "Authorization: Bearer $REPLIFIER_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "My system", "url": "https://mydomain.com/hooks/replifier", "events": ["message.sent", "message.failed"] }'

The available events are message.sent, message.failed, contact.created, contact.updated, contact.unsubscribed, campaign.sent, campaign.failed, campaign.started, flow.email_sent, whatsapp.message.received, whatsapp.message.status, whatsapp.template.status, message.received, message.delivered, message.read, message.replied, link.clicked, and conversion.recorded. The response carries the secret field, only once: keep it in an environment variable. If you lose it or suspect it leaked, rotate it with POST /v1/brands/{brandId}/webhooks/{whkId}/rotate-secret, which returns a new one.

The URL cannot point to localhost or to private network addresses, and Replifier does not follow redirects.

Every delivery is a POST with a JSON body and these headers:

Header Content
X-Replifier-Signature The signature, in the form sha256=<hexadecimal>.
X-Replifier-Event The event type, for example message.sent.
X-Replifier-Delivery The unique identifier of the delivery. Use it to ignore duplicates.

Answer with a 2xx code in under 5 seconds; anything else counts as a failure. Replifier retries up to 6 times, at 1 minute, 5 minutes, 30 minutes, 2 hours, 8 hours and 24 hours after the previous attempt. Because a retry can repeat a delivery, process each X-Replifier-Delivery only once. You can see deliveries with GET /v1/brands/{brandId}/webhooks/{whkId}/deliveries and resend one with POST …/deliveries/{wdlId}/redeliver.

The signature is the HMAC-SHA256, in hexadecimal, of the raw body of the request, with your secret as the key, preceded by sha256=. Three rules prevent the most common mistakes:

  1. Sign the raw body, exactly as it arrived. If you parse it into an object and serialize it again, spacing and order change and the signature no longer matches.
  2. Compare in constant time, with your language’s function, not with ==, so nobody can deduce the signature by measuring timings.
  3. Answer 401 and process nothing if the signature does not match.
import { createHmac, timingSafeEqual } from 'node:crypto'
import express from 'express'
const app = express()
// express.raw keeps the body exactly as it arrived.
app.post('/hooks/replifier', express.raw({ type: 'application/json' }), (req, res) => {
const expected = 'sha256=' + createHmac('sha256', process.env.REPLIFIER_WEBHOOK_SECRET).update(req.body).digest('hex')
const received = req.get('X-Replifier-Signature') ?? ''
const ok = received.length === expected.length && timingSafeEqual(Buffer.from(received), Buffer.from(expected))
if (!ok) return res.sendStatus(401)
const event = JSON.parse(req.body.toString('utf8'))
console.log(req.get('X-Replifier-Event'), req.get('X-Replifier-Delivery'), event)
res.sendStatus(200)
})
app.listen(3000)
<?php
$raw = file_get_contents('php://input'); // the raw body
$expected = 'sha256=' . hash_hmac('sha256', $raw, getenv('REPLIFIER_WEBHOOK_SECRET'));
$received = $_SERVER['HTTP_X_REPLIFIER_SIGNATURE'] ?? '';
if (!hash_equals($expected, $received)) {
http_response_code(401);
exit;
}
$event = json_decode($raw, true);
error_log($_SERVER['HTTP_X_REPLIFIER_EVENT'] . ' ' . $_SERVER['HTTP_X_REPLIFIER_DELIVERY']);
http_response_code(200);
import hashlib
import hmac
import os
from flask import Flask, abort, request
app = Flask(__name__)
@app.post("/hooks/replifier")
def replifier_hook():
raw = request.get_data() # the raw body
expected = "sha256=" + hmac.new(os.environ["REPLIFIER_WEBHOOK_SECRET"].encode(), raw, hashlib.sha256).hexdigest()
received = request.headers.get("X-Replifier-Signature", "")
if not hmac.compare_digest(expected, received):
abort(401)
event = request.get_json()
print(request.headers["X-Replifier-Event"], request.headers["X-Replifier-Delivery"], event)
return "", 200

To check your code without waiting for a real delivery, sign a test body with openssl and compare it with what your server computes:

Terminal window
BODY='{"hello":"world"}'
printf 'sha256=%s\n' "$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$REPLIFIER_WEBHOOK_SECRET" -hex | sed 's/^.* //')"
curl -X POST http://localhost:3000/hooks/replifier \
-H "Content-Type: application/json" \
-H "X-Replifier-Signature: sha256=<the signature above>" \
-d "$BODY"

The body of each delivery depends on the event. Below are the fields of each group; a later version may add fields, so ignore the ones you do not know. For an exact sample of any event, call GET /v1/hooks/samples/{event}.

These events are a flat JSON with the event field and the ones in the table. id is the identifier of the send, the contact or the campaign, depending on the event.

Event Fields
message.sent, message.failed id, brandId
contact.created, contact.updated id, brandId
contact.unsubscribed contactId, listId, brandId
campaign.started, campaign.sent id
campaign.failed id, reason
flow.email_sent flowId, nodeId, contactId, sendId, campaignId

whatsapp.message.received, whatsapp.message.status and whatsapp.template.status report messages received, delivery status and template review. Their fields are described in the WhatsApp API reference.

message.received, message.delivered, message.read, message.replied, link.clicked and conversion.recorded share an envelope with id, type (the same as the event), created_at and data. For example, a click:

{
"id": "evt_…",
"type": "link.clicked",
"created_at": "2026-01-01T00:00:00.000Z",
"data": {
"message_id": "ccm_…",
"contact_id": "ctc_…",
"brand_id": "brd_…",
"campaign_id": "cmp_…",
"channel": "email",
"url": "https://example.com"
}
}

data carries only identifiers, never the content of the message: message_id, contact_id, brand_id, and campaign_id and channel when they apply (for example whatsapp or email). Keys with no value are left out. link.clicked adds url, and conversion.recorded adds amount, currency and order_id. message.delivered and message.read are sent for WhatsApp and SMS messages.

Your endpoint answers 200 to a delivery signed with your secret, answers 401 if you change a single character of the body or the signature, and processes each X-Replifier-Delivery only once.