Source of truth: the live API reference and the OpenAPI document at
https://connect.rylixfleet.com/api/v1/openapi.json. If this wiki and they ever disagree, they win.
Every webhook carries:
Rylix-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256>
whsec_…), shown once when it is created.v1 is the hex HMAC-SHA256 of the timestamp, a dot, and the raw request body ("<t>.<raw body>"), with the secret (as UTF-8 bytes) as the key.Then deduplicate by the event id.
This is the snippet the live reference shows, which Rylix's own tests run against a real signed request.
import { createHmac, timingSafeEqual } from "node:crypto";
export function verifyRylixSignature(rawBody, header, secret, toleranceSeconds = 300) {
const parts = Object.fromEntries(
String(header ?? "").split(",").map((part) => {
const at = part.indexOf("=");
return [part.slice(0, at).trim(), part.slice(at + 1).trim()];
}),
);
const timestamp = Number(parts.t);
const signature = parts.v1 ?? "";
if (!Number.isInteger(timestamp) || !/^[0-9a-f]{64}$/.test(signature)) return false;
if (Math.abs(Date.now() / 1000 - timestamp) > toleranceSeconds) return false;
const expected = createHmac("sha256", secret).update(`${timestamp}.${rawBody}`).digest();
return timingSafeEqual(expected, Buffer.from(signature, "hex"));
}
Receiver (Express, raw body):
import express from "express";
const app = express();
const webhookSecret = process.env.RYLIX_WEBHOOK_SECRET; // whsec_…, shown once
app.post("/rylix/webhooks", express.text({ type: "application/json" }), (req, res) => {
if (!verifyRylixSignature(req.body, req.get("Rylix-Signature"), webhookSecret)) {
return res.status(400).end();
}
const event = JSON.parse(req.body);
// Deduplicate by event.id: a retry or a resend carries the same id.
res.status(200).end(); // answer fast, then do the work
});
import hashlib
import hmac
import re
import time
def verify_rylix_signature(raw_body: bytes, header: str, secret: str, tolerance_seconds: int = 300) -> bool:
parts = {}
for part in (header or "").split(","):
key, sep, value = part.partition("=")
if sep:
parts[key.strip()] = value.strip()
timestamp = parts.get("t", "")
signature = parts.get("v1", "")
if not timestamp.isdigit() or not re.fullmatch(r"[0-9a-f]{64}", signature):
return False
if abs(time.time() - int(timestamp)) > tolerance_seconds:
return False
signed = timestamp.encode() + b"." + raw_body
expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)
Receiver (Flask):
import os
from flask import Flask, abort, request
app = Flask(__name__)
WEBHOOK_SECRET = os.environ["RYLIX_WEBHOOK_SECRET"] # whsec_..., shown once
@app.post("/rylix/webhooks")
def rylix_webhook():
raw = request.get_data() # the raw bytes, before any JSON parsing
if not verify_rylix_signature(raw, request.headers.get("Rylix-Signature", ""), WEBHOOK_SECRET):
abort(400)
event = request.get_json()
# Deduplicate by event["id"]: a retry or a resend carries the same id.
return "", 200
<?php
function verify_rylix_signature(string $rawBody, ?string $header, string $secret, int $toleranceSeconds = 300): bool
{
$parts = [];
foreach (explode(',', (string) $header) as $part) {
$at = strpos($part, '=');
if ($at !== false) {
$parts[trim(substr($part, 0, $at))] = trim(substr($part, $at + 1));
}
}
$timestamp = $parts['t'] ?? '';
$signature = $parts['v1'] ?? '';
if (!ctype_digit($timestamp) || !preg_match('/^[0-9a-f]{64}$/', $signature)) {
return false;
}
if (abs(time() - (int) $timestamp) > $toleranceSeconds) {
return false;
}
$expected = hash_hmac('sha256', $timestamp . '.' . $rawBody, $secret);
return hash_equals($expected, $signature);
}
Receiver (plain PHP):
<?php
$rawBody = file_get_contents('php://input'); // the raw body, before json_decode
$header = $_SERVER['HTTP_RYLIX_SIGNATURE'] ?? null;
$secret = getenv('RYLIX_WEBHOOK_SECRET'); // whsec_..., shown once
if (!verify_rylix_signature($rawBody, $header, $secret)) {
http_response_code(400);
exit;
}
$event = json_decode($rawBody, true);
// Deduplicate by $event['id']: a retry or a resend carries the same id.
http_response_code(200);
The Python and PHP functions were checked against signatures made with Rylix's algorithm: a valid signature passes, and a changed body or a timestamp older than 300 seconds fails.
A secret cannot be shown again. To rotate it, add a new endpoint (same URL is fine), deploy the new secret, then delete the old endpoint.