For arlanix/notification 1.1.0
Webhook
You can receive a topic's notifications in your own service as JSON over HTTPS. A Webhook subscription sends one POST per delivery, carrying a digest of up to 25 different messages. A repeated message is one entry with its count, so total can exceed 25. Store teams set the URL, optional signing secret and optional headers on the subscription; see the manual.
Your receiver must be reachable directly from the store. The webhook never uses the store's HTTP proxy. A store whose egress must use a proxy cannot use it. The request times out after 10 seconds, and the store never follows redirects.
Payload v1
The request body has these fields:
| Field | Type | Meaning |
|---|---|---|
version |
integer | 1. |
id |
string | 32 hexadecimal characters identifying this attempt. It changes on every attempt. |
sent_at |
string | Attempt time in ISO 8601 UTC with a Z suffix. |
topic |
string | Topic name. |
severity |
string | info, warning or error: the worst severity in the digest. |
subject |
string | Subject of the whole digest. |
body |
string | Plain text of the whole digest. |
total |
integer | Number of messages, including repeats. |
entries |
array of objects | Messages grouped into digest entries. |
Each object in entries has these fields:
| Field | Type | Meaning |
|---|---|---|
delivery_ids |
array of integers | Stable delivery identifiers across retries. Use these as the deduplication key. Empty for Send test message. |
subject |
string | Message subject. |
body |
string | Message body. |
severity |
string | info, warning or error. |
source |
string | Message source. |
attributes |
object with string values | Message attributes; an object even when empty. |
count |
integer | Number of times this message appears in the digest. |
first_at |
string | First publication time in ISO 8601 UTC with a Z suffix. |
last_at |
string | Last publication time in ISO 8601 UTC with a Z suffix. |
Record the delivery_ids you process. A retry can put a message in a different digest, with a different attempt id. Deduplicate each delivery identifier rather than the request id or the entire digest.
Request headers
The store sends these headers, together with your subscription's custom headers:
| Header | Value |
|---|---|
Content-Type |
application/json |
User-Agent |
Arlanix-Notification by default; a custom User-Agent header replaces it, regardless of the header name's case. |
X-Arlanix-Timestamp |
Unix time in seconds; present only with a signing secret. |
X-Arlanix-Signature |
v1= followed by the hexadecimal HMAC-SHA256; present only with a signing secret. |
Custom headers cannot use Host, Content-Type, Content-Length, Transfer-Encoding, Connection or any X-Arlanix-* name. Names must be valid HTTP header tokens and unique without regard to case. Values cannot contain control characters other than tab (bytes 0x00–0x1F, except 0x09, and 0x7F are refused). The store sets Content-Type and the signing headers; custom headers cannot replace them. A subscription accepts at most 10 custom headers. See the manual for stored values and edits.
Verify the signature
Set a Signing secret on the subscription and give your receiver the same secret. Compute HMAC-SHA256 over the timestamp header, a literal dot, and the raw request body bytes, using that secret. Compare the hexadecimal result with the value after v1= in constant time. Refuse timestamps more than 300 seconds before or after the receiver's time.
Read the raw body before parsing JSON. Re-encoding JSON can change whitespace, escaping or key order and invalidate the signature. These examples verify and acknowledge a request; add your application's processing before the successful response.
PHP
Use this as a PHP endpoint, with php://input providing the raw bytes:
<?php
declare(strict_types=1);
$secret = getenv('SIGNING_SECRET');
if ($secret === false || $secret === '') {
http_response_code(500);
exit;
}
$rawBody = file_get_contents('php://input');
$timestamp = $_SERVER['HTTP_X_ARLANIX_TIMESTAMP'] ?? '';
$signature = $_SERVER['HTTP_X_ARLANIX_SIGNATURE'] ?? '';
$seconds = filter_var($timestamp, FILTER_VALIDATE_INT);
if ($rawBody === false || !ctype_digit($timestamp)
|| $seconds === false || abs(time() - $seconds) > 300
|| preg_match('/\Av1=([a-f0-9]{64})\z/', $signature, $match) !== 1
) {
http_response_code(401);
exit;
}
$expected = hash_hmac('sha256', $timestamp . '.' . $rawBody, $secret);
if (!hash_equals($expected, $match[1])) {
http_response_code(401);
exit;
}
// The raw body is verified. Process it before acknowledging the delivery.
http_response_code(204);
Set the receiver's SIGNING_SECRET environment variable to the subscription's Signing secret. The example returns 401 for a missing or invalid signature or a timestamp outside the tolerance, and 204 after verification.
Node
Save this as receiver.mjs and run it with Node. It collects raw body buffers without a JSON body parser:
import { createServer } from 'node:http';
import { createHmac, timingSafeEqual } from 'node:crypto';
const MAX_BODY_BYTES = 1024 * 1024;
const secret = process.env.SIGNING_SECRET;
if (!secret) throw new Error('Set SIGNING_SECRET');
createServer(async (req, res) => {
try {
const chunks = [];
let size = 0;
for await (const chunk of req.iterator({ destroyOnReturn: false })) {
size += chunk.length;
if (size > MAX_BODY_BYTES) {
res.writeHead(413, { Connection: 'close' }).end();
return;
}
chunks.push(chunk);
}
const rawBody = Buffer.concat(chunks);
const timestamp = req.headers['x-arlanix-timestamp'];
const signature = req.headers['x-arlanix-signature'];
const seconds = Number(timestamp);
const match = typeof signature === 'string'
? /^v1=([a-f0-9]{64})$/.exec(signature) : null;
if (typeof timestamp !== 'string' || !/^[0-9]+$/.test(timestamp)
|| !Number.isSafeInteger(seconds)
|| Math.abs(Math.floor(Date.now() / 1000) - seconds) > 300
|| !match
) {
res.writeHead(401).end();
return;
}
const expected = createHmac('sha256', secret)
.update(timestamp + '.').update(rawBody).digest();
const received = Buffer.from(match[1], 'hex');
if (received.length !== expected.length
|| !timingSafeEqual(expected, received)
) {
res.writeHead(401).end();
return;
}
// The raw body is verified. Process it before acknowledging delivery.
res.writeHead(204).end();
} catch {
res.writeHead(400).end();
}
}).listen(8080);
Set the receiver's SIGNING_SECRET environment variable to the subscription's Signing secret. This example listens on port 8080; expose it through your HTTPS server. It returns 413 for bodies over 1 MiB, 401 for verification failures and 204 after verification. Keep a body-size limit in the HTTPS server in front of it too.
Address policy
The store accepts only HTTPS URLs without credentials in the URL. Put credentials in custom headers. Backslashes, whitespace, control characters and a trailing dot on the host are refused. A numeric IPv4 host must use plain dotted-quad notation.
The store checks every A and AAAA answer when you save and again before every send. It refuses the host if any answer is in a forbidden range, or if the host has no address. The IPv4 policy refuses these ranges:
| Addresses | Refused ranges |
|---|---|
| Loopback and the zero network | 127.0.0.0/8, 0.0.0.0/8 |
| Private | 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 |
| Link-local and carrier-grade NAT | 169.254.0.0/16, 100.64.0.0/10 |
| Protocol assignments and 6to4 relay | 192.0.0.0/24, 192.88.99.0/24 |
| Documentation | 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 |
| Benchmark | 198.18.0.0/15 |
| Multicast, reserved and broadcast | 224.0.0.0/4, 240.0.0.0/4, 255.255.255.255/32 |
For IPv6, the policy accepts only global unicast 2000::/3, excluding 2001::/23 and documentation range 2001:db8::/32, with these exceptions checked by their embedded IPv4 address against the IPv4 policy:
- IPv4-mapped:
::ffff:0:0/96. - IPv4-compatible:
::/96. - NAT64:
64:ff9b::/96. - 6to4:
2002::/16.
The policy always refuses ::, ::1 and local-use NAT64 64:ff9b:1::/48. Apart from the embedded-IPv4 exceptions, it refuses everything outside 2000::/3, including unique-local, link-local, site-local and multicast addresses.
The connection is pinned to the checked IP address. It connects directly, bypassing the store's HTTP proxy so that a proxy cannot resolve the host again. Redirects are never followed; an HTTP 3xx response fails the attempt.
Responses and retries
Your receiver's response controls the outcome:
| Response | Outcome |
|---|---|
| HTTP 2xx | The store marks the delivery as sent. |
| HTTP 429 | The store waits for Retry-After, or 60 seconds if no wait is given. The wait is at most 3600 seconds. |
| Any other HTTP status | The attempt fails. The operator sees the host, status and up to 200 characters of the answer, with tags stripped and echoed secrets, including URL path segments and query values of six characters or more, replaced by [redacted]. |
| No answer within 10 seconds | The attempt fails with a connection error naming the host. |
Failed deliveries use Retry after (minutes) (arlanix_notification/delivery/retry_minutes), by default 1, 5, 15, 60 and 240 minutes. See Configuration to set the schedule. Each attempt gets a different id; its signature timestamp records when it is sent. Keep using entries[].delivery_ids for deduplication across attempts. See Queue, cron and command line for queue operation, and the manual for operator messages.