Webhooks
SplitTesty sends an HTTPS POST request to your endpoint when a subscribed event happens. Endpoints are managed by admins under Settings → Webhooks.
Events
| Event | Sent when |
|---|---|
campaign.status_changed | A campaign was started, paused, scheduled, archived or restored. |
campaign.winner_found | A variation reached the winner threshold on the primary metric. |
campaign.guardrail_breach | A guardrail metric degraded beyond its tolerated threshold. |
Payload
The body is JSON with a unique id, the event type, the creation time created (Unix seconds) and event-specific data. The event type is also sent in the X-SPT-Event header.
POST /hooks/splittesty HTTP/1.1
Content-Type: application/json
User-Agent: SplitTesty-Webhooks/1.0
X-SPT-Event: campaign.status_changed
X-SPT-Signature: t=1795627297,v1=m4yWeqPO2ZqrQw-r9qiyeFhfhjlu4M3El3J2V8-iJ9k
{
"id": "evt_5f1c0a9e3b7d42a6c8e0",
"type": "campaign.status_changed",
"created": 1795627297,
"data": {
"campaignId": 42,
"name": "Pricing page headline",
"type": "ab",
"from": "draft",
"to": "running",
"reason": null
}
}Verifying the signature
Every request carries the header X-SPT-Signature: t=<unix>,v1=<signature>. The signature is the base64url-encoded (no padding) HMAC-SHA256 of the string t + "." + body, keyed with the endpoint’s signing secret (whsec_…).
Compute the signature over the raw request body exactly as received, compare in constant time and reject timestamps older than a few minutes to prevent replays.
Node.js example
import { createHmac, timingSafeEqual } from 'node:crypto';
import express from 'express';
const SECRET = process.env.SPT_WEBHOOK_SECRET; // whsec_…
const TOLERANCE_SECONDS = 300;
/** Returns true when the X-SPT-Signature header matches the raw request body. */
export function verifySptSignature(rawBody, header, secret, now = Date.now()) {
const parts = Object.fromEntries(String(header || '').split(',').map((p) => p.trim().split('=')));
const t = Number(parts.t);
if (!Number.isFinite(t) || !parts.v1) return false;
if (Math.abs(now / 1000 - t) > TOLERANCE_SECONDS) return false; // replay protection
// base64url (no padding) HMAC-SHA256 of "<t>.<body>"
const expected = createHmac('sha256', secret).update(t + '.' + rawBody).digest('base64url');
const a = Buffer.from(expected);
const b = Buffer.from(parts.v1);
return a.length === b.length && timingSafeEqual(a, b);
}
const app = express();
// keep the RAW body: the signature is computed over the exact bytes that were sent
app.post('/hooks/splittesty', express.raw({ type: 'application/json' }), (req, res) => {
const rawBody = req.body.toString('utf8');
if (!verifySptSignature(rawBody, req.get('X-SPT-Signature'), SECRET)) {
return res.status(401).send('invalid signature');
}
const event = JSON.parse(rawBody);
res.sendStatus(204); // acknowledge quickly, then process
if (event.type === 'campaign.status_changed' && !event.data.test) {
console.log('Campaign', event.data.campaignId, 'is now', event.data.to);
}
});
app.listen(3001);Delivery and retries
- Answer with any 2xx status within 10 seconds. Do the real work asynchronously.
- Network errors and 5xx responses are retried after 1 minute, 5 minutes and 30 minutes (4 attempts in total). 4xx responses are not retried.
- Retries re-send the same event with a fresh timestamp and signature; use the event
idto ignore duplicates. - The last deliveries of each endpoint are listed in the settings page, where you can also send a test event.
Test events
“Send test” delivers a campaign.status_changed event whose data is { "test": true }.