Server verification
If your game talks to a server of its own — multiplayer, trading, a competitive leaderboard — that server needs to know who is connected. Players can send anything, so don’t trust a name. Trust a ticket, checked with your game’s secret.
-
Create the secret.
In Developer dashboard → your game → SDK → Server secret, press Create secret. Copy it (
gs_…) into your server’s configuration — an environment variable or your host’s secret store.Spawnle keeps only a hash of it and never shows it again. Never ship it inside the game: anyone could extract it.
-
Send the ticket from the game.
const spawnle = await Spawnle.init({ requireSpawnle: true });socket.send(JSON.stringify({ type: "hello", ticket: spawnle.ticket }));Native games send
SPAWNLE_TICKET. -
Verify it on your server.
POST /v1/sdk/verify HTTP/1.1Host: api.spawnle.comContent-Type: application/jsonX-Spawnle-Game-Secret: gs_3b1f…{ "ticket": "gt_9f2c…" }200 OK {"handle": "sofi_moth","display_name": "Sofi","game": "neon-moth","expires_at": 1795820291}A wrong or rotated secret, an expired ticket, or a ticket for another game answers
401 unauthorized.
Example (Node.js)
Section titled “Example (Node.js)”const SECRET = process.env.SPAWNLE_GAME_SECRET;
async function whoIs(ticket) { const response = await fetch("https://api.spawnle.com/v1/sdk/verify", { method: "POST", headers: { "content-type": "application/json", "x-spawnle-game-secret": SECRET }, body: JSON.stringify({ ticket }), }); if (!response.ok) return null; // reject the connection return response.json(); // { handle, display_name, game, expires_at }}Cache the answer for the connection’s lifetime instead of verifying every message. Verification allows 600 requests per minute per server address.
Acting for the player
Section titled “Acting for the player”With a verified ticket your server can also call the SDK routes itself — for example, submit a score only after checking the run was legitimate.
Rotating the secret
Section titled “Rotating the secret”Create a new secret replaces the old one immediately: every server still
using the old secret starts getting 401. Update your servers right after.