Verify the signature
Prove that a callback came from AGIXX before money moves.
On this page
Signature headers#
Requests to your callbackUrl (balance, auth, bet, win, betwin, rollback and Validator runs) are signed with HMAC-SHA256 using your API key secret. The secret is issued once with the key; keep it on your server only.
| Header | Example | Content |
|---|---|---|
X-AGIXX-Timestamp | 1761300000 | Unix time in seconds when we signed |
X-AGIXX-Key-Id | pk_live_1a2b3c4d | First 16 characters of the API key whose secret signed the request |
X-AGIXX-Signature | sha256=9f2c... | sha256= and the hex HMAC of the signing string |
Steps#
signature = "sha256=" + hex( HMAC_SHA256( apiKeySecret, X-AGIXX-Timestamp + "." + rawBody ) )
X-AGIXX-Timestamp: 1761300000
rawBody: {"action":"bet","playerId":"player_123", ... }
signing string: 1761300000.{"action":"bet","playerId":"player_123", ... }- 1Read the raw body exactly as received, before JSON parsing. In Express, register
express.rawfor this route before any globalexpress.json. - 2Pick the secret by
X-AGIXX-Key-Id. - 3Build the signing string: timestamp, a dot, the raw body.
- 4Compute HMAC-SHA256, hex-encode it, prefix
sha256=and compare in constant time (crypto.timingSafeEqual/hash_equals). - 5Reject a timestamp more than 5 minutes from your clock, and keep the clock in sync (NTP). Answer a bad signature with 401.
Node.js: verification is part of the runnable wallet sample.
<?php
// Verify an AGIXX callback before touching the wallet
$secrets = [ // key id => that key's secret
'pk_live_1a2b3c4d' => getenv('AGIXX_API_SECRET'),
];
$raw = file_get_contents('php://input'); // exact raw body, before json_decode
$ts = $_SERVER['HTTP_X_AGIXX_TIMESTAMP'] ?? '';
$sig = $_SERVER['HTTP_X_AGIXX_SIGNATURE'] ?? '';
$secret = $secrets[$_SERVER['HTTP_X_AGIXX_KEY_ID'] ?? ''] ?? null;
header('Content-Type: application/json');
// Unknown key, or stale / replayed request (more than 5 minutes off)
if (!$secret || !ctype_digit($ts) || abs(time() - (int) $ts) > 300) {
http_response_code(401);
exit(json_encode(['message' => 'Stale or unknown signature']));
}
$expected = 'sha256=' . hash_hmac('sha256', $ts . '.' . $raw, $secret);
if (!hash_equals($expected, $sig)) { // constant-time compare
http_response_code(401);
exit(json_encode(['message' => 'Invalid signature']));
}
$event = json_decode($raw, true);
// Continue exactly like handle() in the Node.js sample, then reply HTTP 200 + JSON:
// echo json_encode(['code' => 0, 'balance' => 990.00, 'transaction_id' => $event['transactionId']]);Which secret, and rotation#
- The secret of the API key the session was launched with; if that key was revoked or expired, your newest active key. Validator runs use the key that started the run.
- Rotation replaces the key and its secret at once, also for games already open: the next callback uses the new key id and secret, and the old key stops launching. Agree on the moment with us and accept both secrets around it.
- If your account has no active key, callbacks are sent unsigned. Keep rejecting them and write to integration@agixx.net.
- Adding verification to an existing wallet: first log failures without rejecting, then enforce. Rejecting a genuine request is a failed wallet call.
IP allow-listCallbacks currently leave from 38.244.144.71. You can also allow-list it, in addition to the signature and never instead of it. Ask us before relying on it: the address can change.
Questions about your integration?Write to us with your account name and, if you have one, a sessionId or transactionId. integration@agixx.net