Signed server events
A conditional server-to-server contract; never ship integration credentials in a game.
Downloads for this guide
Server signing helperNode.js module; server only; no credentials included.Prerequisites
Staff must provision or rotate the game-scoped integration key. Your game server must validate gameplay and securely associate the platform session with its own authenticated run. The platform does not implement that association for every external engine. A browser-provided sessionId alone is not proof of identity or score.
Signing contract
POST /api/v1/integrations/game-events uses X-Play-Key (64 lowercase hex characters), X-Play-Timestamp (13-digit Unix milliseconds) and X-Play-Signature (lowercase HMAC-SHA256 hex). Sign the exact bytes: timestamp + '.' + raw JSON body. The timestamp must be within five minutes of the server clock. JSON includes sessionId and the normal game event fields. Key lookup, signature, scope and session/event validation all run server-side.
// SERVER ONLY. Run with Node 22+. Never copy this key into a game or frontend.
import { createHmac, randomUUID } from 'node:crypto';
export async function reportVerifiedEvent({ origin, key, sessionId, name, data, eventId = randomUUID() }) {
// Authoritatively validate gameplay on your server BEFORE calling this helper.
// A browser-provided sessionId is correlation data, not identity or proof.
if (!/^https:\/\//.test(origin)) throw Error('Use an HTTPS platform origin.');
if (!/^[a-f0-9]{64}$/.test(key || '')) throw Error('A staff-issued server integration key is required.');
// Omit protocolVersion/sequence intentionally: legacy/unsequenced reports are
// supported here and do not compete with the browser SDK's V2 sequence.
const body=JSON.stringify({eventId,sessionId,name,data});
const timestamp=String(Date.now());
const signature=createHmac('sha256',key).update(timestamp+'.').update(body).digest('hex');
const response=await fetch(new URL('/api/v1/integrations/game-events',origin),{method:'POST',headers:{'Content-Type':'application/json','X-Play-Key':key,'X-Play-Timestamp':timestamp,'X-Play-Signature':signature},body});
if (!response.ok) throw Error(`Platform rejected server event (${response.status}): ${await response.text()}`);
return response.json();
}Ordering and idempotency
The provided helper uses the supported legacy unsequenced envelope so it does not invent a competing V2 counter. Do not have browser and server both report the same terminal outcome; coordinate a single authority. Reuse the same eventId and exact payload if retrying an uncertain accepted report. Always re-sign with a current timestamp. Session expiry and registration rules still apply.
Limits
The sample does not contain a key, auto-provision a server, verify gameplay or establish user identity. It is a signing utility for an already approved integration, not a complete multiplayer backend or a browser workaround.