Skip to content

API reference

Everything is JSON. IDs are generated by the server, so never send an id.

Base URLs

Where Base URL
dotnet watch http://localhost:5008
Vite dev server http://localhost:5173 (proxies /api to :5008)
Full Docker, locally http://localhost:8090
Production, over the SSH tunnel http://localhost:8090
Production, public https://51.79.242.169.nip.io — /Health, the player-auth routes (register, login/device, login/email, display-name, link/email, email/verify, email/resend, password/forgot, password/reset) and the game server's /api/server/* routes (which need a server key)

Only these paths are publicly reachable

Caddy is default-deny. Every other path on the public domain returns 404 with an empty body, including the admin API. Use the SSH tunnel.

Authentication

There are three separate kinds of credential, and one from one kind is useless on the others.

Admins — every endpoint except /Health, POST /api/admin/login and the player-auth routes needs a logged-in admin session cookie. /api/admin/admins needs the owner specifically. The cookie (hakutaku_admin_session) is HttpOnly, so a browser handles it automatically and JavaScript cannot read it. With curl you need a cookie jar: -c to save, -b to send.

Players — register and login return a token. Send it back as Authorization: Bearer <token>. A player token currently unlocks only display-name, link/email, email/verify and email/resend; the rest of the game data is still admin-only.

Game servers — a server key, sent in the X-Server-Key header, opens the /api/server/* routes and nothing else. The owner makes keys on the Server keys page, or with POST /api/admin/server-keys. A server key never works on /api/admin/*, and an admin cookie or a player token never works on /api/server/*.

See Auth and sessions for the mechanics.

Every endpoint

Method Path Guard Purpose
GET /Health — Liveness check
POST /api/admin/login Rate-limited Sign in, sets the session cookie
POST /api/admin/logout Session Revoke the session, clear the cookie
GET /api/admin/me Session Who the current cookie belongs to
GET /api/admin/admins Owner List all admins, including deactivated
POST /api/admin/admins Owner Create an admin
DELETE /api/admin/admins/{id} Owner Deactivate an admin
GET /api/admin/server-keys Owner List server keys, never the keys themselves
POST /api/admin/server-keys Owner Make a server key; the key comes back once
DELETE /api/admin/server-keys/{id} Owner Revoke a server key
GET /api/server/ping Server key, public Check that a server key works
POST /api/server/sessions/validate Server key, public Check a player's session ticket; returns their id and display name
GET /api/server/players/{id}/data Server key, public Read a player's data in one tier
POST /api/server/players/{id}/data Server key, public Set and remove keys in one tier of a player's data
POST /api/server/events/batch Server key, public Store up to 500 telemetry events (the ingestion service calls it)
POST /ingest/events Server key, public Send telemetry events to the ingestion service (not the app; see Telemetry ingestion)
POST /api/players/register Rate-limited, public Make a guest player; returns its device token (once) and a session
POST /api/players/login/device Rate-limited, public Sign in with a device token; never creates a player
POST /api/players/display-name Player token, public, limited per player Set the current player's display name
POST /api/players/link/email Player token, public Add an email + password to the current player
POST /api/players/login/email Rate-limited, public Sign in with email + password, returns a session token
POST /api/players/email/verify Player token, rate-limited Confirm the emailed 6-digit code
POST /api/players/email/resend Player token, rate-limited Mail a new verification code
POST /api/players/password/forgot Rate-limited, public Mail a password-reset code
POST /api/players/password/reset Rate-limited, public Set a new password with the code
GET /api/admin/stats Admin The Overview page's numbers: unique users, new users and logins, by period and by day
GET /api/players Admin List all players (id, display name, linked providers, created, last login)
POST /api/players Admin Create a player
GET /api/players/{id} Admin One player: a list row plus each linked account (provider, when linked, verified)
GET /api/players/{id}/data Admin Every tier of a player's data, with when each key was set
POST /api/players/{id}/data Admin Set and remove keys in any tier, logged with the admin's username
GET /api/characters Admin List all characters
POST /api/characters Admin Create a character
GET /api/events Admin List all telemetry events
POST /api/events Admin Record a telemetry event

There is no PUT and no DELETE on game data, and list endpoints return the entire table — no paging, no filtering.

Planned changes

The game-data paths are intended to become singular (/api/players → /api/player). Characters and events will open to player tokens once the player API is designed. player_bans does not exist yet.


Health

curl http://localhost:5008/Health
# {"health":"ok"}

Public through Caddy, because the Jenkins smoke test uses it.

The capital H matters

The route is /Health, and Caddy's handle /Health matcher is case-sensitive. /health is not published.


Admin: sign in

curl -c cookies.txt -X POST http://localhost:5008/api/admin/login \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"<password>"}'
# 204, Set-Cookie: hakutaku_admin_session=...

Body: username (string), password (string).

Login is by username, not email. Matching is case-insensitive and the username is trimmed.

Status When Body
204 Success Empty — the cookie is in the header
400 Missing field, or username > 254 / password > 256 chars { "error": "username and password are required" }
401 Wrong password, unknown username, or disabled account { "error": "invalid credentials" }
429 More than 5 attempts per minute from one IP Empty body

Two client traps here

204 means res.json() throws — there is no body to parse. And 429 is the only error status without an { error } body, because it comes from the framework's rate limiter rather than from handler code.

All three failure cases return the same 401 on purpose, so the API does not reveal which usernames exist.

Admin: who am I

curl -b cookies.txt http://localhost:5008/api/admin/me
# {"username":"admin","email":null,"role":"owner"}

role is "owner" or "admin". Nothing else is possible.

This is how a front end discovers whether its cookie is still good without asking for a password again. 401 if there is no cookie, or the session has expired or been revoked.

Never call this on a timer

It is an authenticated request, so it pushes the 30-minute idle expiry forward. Polling it means the idle timeout can never fire. Call it on app load and on route changes.

Admin: sign out

curl -b cookies.txt -X POST http://localhost:5008/api/admin/logout
# 204, clears the cookie

Returns 401 if you were not logged in. Treat that as "already logged out" rather than an error.

Admin: list admins

curl -b cookies.txt http://localhost:5008/api/admin/admins
[
  { "id": 1, "username": "admin", "role": "owner",
    "createdAt": "2026-09-25T09:52:16Z", "disabledAt": null },
  { "id": 5, "username": "bob", "role": "admin",
    "createdAt": "2026-10-01T04:10:00Z", "disabledAt": "2026-10-01T05:00:00Z" }
]

Owner only. Includes deactivated admins — disabledAt is non-null for those — so the UI can show state and target a deactivation.

Ordered by id.

Admin: create an admin

curl -b cookies.txt -X POST http://localhost:5008/api/admin/admins \
  -H "Content-Type: application/json" \
  -d '{"username":"bob","password":"a-real-password"}'
# 200 {"id":5,"username":"bob","role":"admin"}

Body: username (string, ≤ 254), password (string, 8–256).

Always creates a regular admin. There is exactly one owner — seeded at first start — and this endpoint cannot create another.

Status When
200 Created
400 Missing username, or password outside 8–256 characters
401 Not logged in
403 Logged in as a non-owner admin — { "error": "owner only" }
409 Username already taken (case-insensitively)

Admin: deactivate an admin

curl -b cookies.txt -X DELETE http://localhost:5008/api/admin/admins/5
# 204

Sets disabled_at and immediately revokes that admin's active sessions. Does not hard-delete the row, and there is no restore endpoint.

Status When
204 Deactivated
401 Not logged in
403 Not the owner, or the target is the owner
404 No such admin

One-way, and it burns the username

The unique index on lower(username) covers disabled rows, so that username can never be reused.

The owner account can never be deactivated, whoever asks. The seeder only runs when there are zero admins, so disabling the sole owner would lock everyone out with no HTTP way back in.

Admin: server keys

A game server proves who it is with a server key. Only the owner can make, list and revoke them.

curl -b cookies.txt -X POST http://localhost:5008/api/admin/server-keys \
  -H "Content-Type: application/json" -d '{"name":"homelab","expiresAt":"2027-06-01T00:00:00Z"}'
# 200 {"id":1,"name":"homelab","key":"<the-key>"}

curl -b cookies.txt http://localhost:5008/api/admin/server-keys
# [{"id":1,"name":"homelab","createdAt":"...","expiresAt":"...","revokedAt":null,"lastUsedAt":null}]

curl -b cookies.txt -X DELETE http://localhost:5008/api/admin/server-keys/1
# 204
  • name is required, 100 characters at most, with no control characters. It's only a label, so it doesn't have to be unique.
  • expiresAt is optional (no expiry if left out) and has to be in the future.
  • The key is returned once, in the POST answer and nowhere else. It is 32 random bytes as base64url (43 characters). Only its SHA-256 is stored, so a lost key can't be looked up: make a new one and revoke the old.
  • The list shows each key's name, when it was made, expires, was revoked and was last used. It never shows a key.
  • Revoking sets revoked_at and is one-way. The row is kept, and revoking a key that is already revoked changes nothing.
Status When
200 The key was made (POST), or the list (GET)
204 Revoked
400 Missing or bad name, or an expiresAt that is not in the future
401 Not logged in
403 Not the owner
404 No such server key (DELETE)

Server routes

Every route under /api/server/* needs a server key in the X-Server-Key header. The check is on the whole route group, so a route added there later can't be left open by mistake.

curl -H "X-Server-Key: <the-key>" http://localhost:5008/api/server/ping
# {"ok":true,"keyId":1}
Status When
200 A valid key. ping says which key it was
401 No key, or a key that is unknown, revoked, expired or over 512 characters. The body is {"error": "..."}

With no keys in the table, every server route is refused. A key's last_used_at is written at most once a minute.

These routes are public: Caddy proxies /api/server/*, because the game server calls in over the internet from a homelab, so the key is the protection. On production the base URL is https://51.79.242.169.nip.io. Keep the key in the game server's environment as HAKUTAKU_SERVER_KEY, never in a build or a repo, and revoke it on the keys page if it leaks. A game server in C# or Unity should use the server SDK instead of calling these routes by hand.

Session validate

When a player joins, the game server checks the session ticket the player sends (the token from register or a login) and learns who they are.

curl -X POST -H "X-Server-Key: <the-key>" -H "Content-Type: application/json" \
  https://51.79.242.169.nip.io/api/server/sessions/validate \
  -d '{"ticket":"<the player'"'"'s session token>"}'
# {"playerId":"01a1a5f1-...","displayName":"Sherwyn"}

The ticket is hashed and looked up exactly like a player's own token, and the call writes nothing.

Status When Body
200 A live ticket { "playerId": "...", "displayName": "..." }. displayName is null if they have none
401 The ticket is unknown, revoked or expired, or empty, oversized or garbled { "error": "...", "code": "invalid_ticket" }. Turn the player away
401 The server key was refused { "error": "..." } with no code. A setup problem on the game server, never the player's fault

A bad ticket is always a 401 with the code, never a 400. That way a player can't craft a ticket that gets some other answer the game might mistake for "let them in". Anything that isn't one of those answers (a timeout, no connection, a 5xx) means Hakutaku is down, and the game decides whether to let players in offline. The server SDK's HakutakuServerErrorCode makes the same split.

Player data

A game server keeps per-player values here, such as a player's XP. Each value is one key with a text value, in one of three tiers.

# read: every key in a tier, or just the ones asked for
curl -H "X-Server-Key: <the-key>" \
  "http://localhost:5008/api/server/players/<player-id>/data?tier=ReadOnly&keys=Xp,Level"
# {"data":{"Xp":"1200"}}

# write: set some keys and remove others, in one request
curl -X POST -H "X-Server-Key: <the-key>" -H "Content-Type: application/json" \
  "http://localhost:5008/api/server/players/<player-id>/data?tier=ReadOnly" \
  -d '{"data":{"Xp":"1300"},"keysToRemove":["OldKey"]}'
# {"updated":2}
Tier Meant for
ClientWritable Values the game client may change
ReadOnly Values the client can read but only a game server changes. XP lives here, as the key Xp
Internal Values only the backend reads and writes
  • tier is required on both routes. It is given by name, in any case (readonly works). A missing or unknown tier, and a number like tier=1, get a 400. A server key can use any tier.
  • Values are plain text, as in PlayFab, so a number is sent as a string ("1200") and read back the same way. There is no JSON column.
  • keys on a read is a comma-separated list. A key that doesn't exist is left out of the answer, and with no keys you get every key in that tier. An empty keys=, or a blank entry like Xp,,Foo, is a 400: it is never taken to mean "all of them".
  • A write sets values and never adds to them, so doing the same write twice changes nothing more. Setting and removing happen in one transaction, all or nothing. updated is the number of keys set plus the number of keys actually removed, and removing a key that isn't there is fine.
  • Anything over a limit is a 400 {"error": "..."}, and nothing is written:
Limit Value
Key 1-64 characters from A-Z a-z 0-9 _ . -
Value 16 KB at most (counted in bytes, not characters), no null character, and not null
Keys per tier, per player 100 at most
Keys changed in one request 10 at most, sets and removals together
The same key set and removed in one request not allowed
Status When
200 Read, or written
400 A missing or unknown tier, a bad keys list, or something over a limit
401 No server key, or a key that is unknown, revoked or expired
404 No such player, including an id that isn't a GUID

How a game server must use XP

XP is the ReadOnly key Xp, holding the player's total as text ("1200"). The game server keeps the running total in memory during a match and writes the whole total back. It never sends a "+50", since a write sets and never adds. That makes a repeated write harmless, but it also means a wrong total overwrites the right one. So:

  • Only a successful read sets the starting total. Read Xp when the player joins:
    • A 200 without Xp in data means the player has none yet: start at 0.
    • A failed read is not 0. That covers a timeout, no connection, a 5xx, or a 401 for the server's own key. The game doesn't know the player's real total, so it must never write that player's XP this session. Writing would replace their real total with whatever they earned today. Let them play if the game allows it, but keep their XP unsaved, or retry the read and only start writing once one succeeds.
  • At most one write in flight per player. Don't start a second write for a player while one is still waiting. If the total changes in the meantime, keep only the newest total as "pending" and send it when the current write finishes. A newer total replaces a pending one, and it's never queued behind it. Otherwise two writes can land out of order and leave the older total stored.
  • When to write:
    • When the total has changed, at most every 30 seconds per player.
    • Always on disconnect and always at match end, even inside the 30 seconds. Those are the writes that must not be lost.
    • If a write fails, keep the total pending and try again on the next tick.

In code, with the server SDK:

// on join
var read = await server.GetUserReadOnlyDataAsync(new GetUserDataRequest { PlayerId = id, Keys = new List<string> { "Xp" } });
if (read.Error != null) { xpKnown = false; /* never write this player's XP */ }
else { xpKnown = true; xp = read.Result!.Data.TryGetValue("Xp", out var s) && long.TryParse(s, out var v) ? v : 0; }

// every 30 s if changed, and on disconnect and match end: only when xpKnown, one write at a time
await server.UpdateUserReadOnlyDataAsync(new UpdateUserDataRequest
{
    PlayerId = id,
    Data = new Dictionary<string, string> { ["Xp"] = xp.ToString() },
});

Event batches

POST /api/server/events/batch stores telemetry events in bulk. It's what the ingestion service calls; a game server sends its events to that service, not here.

{ "events": [
    { "playerId": "<player id>", "eventType": "level_up", "data": "{\"level\":3}", "occurredAt": "2026-11-17T09:30:15.123Z" }
] }

→ 200 { "accepted": 1, "rejected": [] }

  • 1 to 500 events. Each is checked by the same rules as POST /api/events (EventRules.cs): a player id, an event type of 1-100 characters, data that is JSON text of at most 10,000 bytes.
  • The good events are stored together in one transaction. Each bad one, including an event for a player that doesn't exist, comes back in rejected as { index, error }, so one broken event never blocks the rest.
  • occurredAt is optional: when the ingestion service received the event, so a batch delayed by retries keeps its real times. It must be within the last 24 hours (up to 5 minutes ahead is allowed for clock drift). Without it the time is now.
Status When
200 The batch was read; see accepted and rejected
400 No events, an empty list, or more than 500; nothing is stored
401 No server key, or a key that is unknown, revoked or expired

Game data

Characters and events still need an admin session. The player-auth routes do not — see below. IDs are GUIDs — treat them as opaque strings; do not parse or format them.

Player registration

curl -X POST http://localhost:5008/api/players/register \
  -H "Content-Type: application/json" \
  -d '{"hardwareId":"<e.g. SystemInfo.deviceUniqueIdentifier>","displayName":"Bob"}'
# {"id":"<player-id>","displayName":"Bob","deviceToken":"<device-token>","token":"<token>","expiresAt":"..."}

No cookie needed. Every call makes a new guest player. Nothing is looked up, so registering the same hardware twice gives two players.

  • deviceToken is the guest's credential. The server mints it (32 random bytes), returns it this once, and stores only its SHA-256. The game must keep it, like a password, and sign in with login/device from then on.
  • hardwareId is required, but it is only recorded (as Players.RegisteredHardwareId) for support and spotting reroll farms. It isn't secret, so it is never used to find or sign in a player.
  • displayName is optional; see the rules.
  • token is a session, valid 30 days. Only its hash is stored.
Status When
200 The new player, its device token and a session
400 Missing hardwareId or over 254 characters (an old client sending deviceId gets this too), or a bad displayName
429 More than 30 per minute from one IP (loose, so a room of players behind one IP can all start at once)

Device login

curl -X POST http://localhost:5008/api/players/login/device \
  -H "Content-Type: application/json" \
  -d '{"deviceToken":"<device-token>"}'
# {"id":"<player-id>","displayName":"Bob","token":"<token>","expiresAt":"..."}

Starts a new session for the guest the token belongs to. It never creates a player: an unknown token gets a 401, and the game should offer "New game" or "I have an account" rather than quietly registering a fresh guest. That silent fresh account is the "I reinstalled and lost everything" bug.

The device token stops working once the player verifies an email (see email/verify). From then on they sign in by email.

Status When
200 The player and a fresh session
400 Missing deviceToken
401 Unknown token, including one removed by email verification
429 More than 60 per minute from one IP (its own limit, separate from email login's, and loose so a room behind one IP can all sign in at once)

Set the display name

curl -X POST http://localhost:5008/api/players/display-name \
  -H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
  -d '{"displayName":"Sir Bob"}'
# {"displayName":"Sir Bob"}

Sets or replaces the name the game shows for the player the token belongs to. The rules are the same everywhere a display name is accepted:

  • trimmed, then 3–25 characters, and no control characters (newlines, tabs, …);
  • not unique: two players can both be "Bob". It's a label, so never use it to identify a player. Use the player id for that.

Limited per player, not per IP: 5 tries an hour, so players behind one shared IP don't use up each other's. Every try with a valid token counts, refused names included. The count is kept in memory, so a server restart resets it.

Status When
200 The name as stored
400 Missing, or breaks the rules above
401 No token, or an unknown, expired or revoked one
429 This player already made 5 tries in the last hour (unlike the per-IP limits, this one has a body: {"error": "..."})
curl -X POST http://localhost:5008/api/players/link/email \
  -H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
  -d '{"email":"player@example.com","password":"at-least-8-chars"}'
# {"provider":"email","email":"player@example.com","verified":false,"verificationSent":true}

Adds an email + password to the player the token belongs to. The device token keeps working until the email is verified, so a mistyped address can't strand a guest. The email is trimmed and lowercased. The password must be 8–256 characters.

Gmail aliases count as one address. Gmail ignores dots and anything after a +, and googlemail.com is the same inbox as gmail.com, so sher.wyn+game@googlemail.com and sherwyn@gmail.com are the same email: the second one to link it gets the same answer as for any taken email. Login, forgot and reset find the account through any of those spellings, and mail still goes to the address as it was typed. Other providers keep dots and + as typed.

The email starts unverified, and a 6-digit code is mailed to it (verificationSent says whether that worked; if not, use email/resend). The link itself is saved either way, and login works before verifying. Only a verified email can reset its password.

Status When
200 Linked
400 Not a plausible email, or the password is the wrong length
401 Missing, unknown, revoked or expired token
409 This player already has an email
429 More than 5 attempts per minute from one IP

A taken email gets the same answer as a free one

If the email already belongs to another player, you still get 200 with the same body as a real link, and no code is made for you. If that player has verified it, they get a heads-up email (at most one per address per hour). That way this route can't be used to find out which emails have accounts. The only cost is that a caller who typed someone else's address sees "code sent" and never gets one.

An unverified email is only held for 24 hours

Until someone verifies it, an address is only a claim. The player who links it first holds it for 24 hours; a link by anyone else in that time gets the taken-email answer above, and nobody is mailed a warning. After that, the next player to link the address replaces the old claim and gets the code, and the old player is left with no email linked. A verified email is never replaced.

Verify an email

curl -X POST http://localhost:5008/api/players/email/verify \
  -H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
  -d '{"code":"123456"}'
# {"verified":true,"deviceTokenRemoved":true}

curl -X POST http://localhost:5008/api/players/email/resend \
  -H "Authorization: Bearer <token>"
# {"sent":true}

Codes are 6 digits, valid for 15 minutes, single use, and die after 5 wrong guesses. A newer code replaces the older one.

Verifying deletes the player's device token, in the same transaction. The email makes the account recoverable, and a device token is a credential that never expires, so there's no reason to keep one. deviceTokenRemoved tells the game to delete its stored copy. The session in use keeps working; after that the player signs in with login/email.

verify status When
200 Verified (also if it already was)
400 Wrong, expired, used-up or malformed code, or no email linked
401 Missing or bad token
429 Over the 5 per minute per IP limit
resend status When
200 A new code was mailed
409 Already verified
429 A code was sent in the last 60 seconds, the player already had 5 verification codes in the last 24 hours (the message says which), or over the per-IP limit
503 The mail server refused or failed

Forgot and reset a password

curl -X POST http://localhost:5008/api/players/password/forgot \
  -H "Content-Type: application/json" -d '{"email":"player@example.com"}'
# {"ok":true}

curl -X POST http://localhost:5008/api/players/password/reset \
  -H "Content-Type: application/json" \
  -d '{"email":"player@example.com","code":"123456","newPassword":"a-new-password"}'
# {"ok":true}

forgot answers 200 whether or not that email has an account, so it can't be used to find out who does. A code is only mailed for a verified email, at most once a minute and 5 a day per player. Past either limit it still answers 200 and just sends nothing, so that can't give an account away either. The code works like a verification code.

reset sets the new password (8–256 characters) and revokes every session the player has. It does not log them in; they sign in again with login/email. (A reset needs a verified email, so the player has no device token left.)

reset status When
200 Password changed
400 Wrong, expired or used-up code, unknown or unverified email, or a bad password length
429 Over the 5 per minute per IP limit

Without an SMTP server nothing is mailed

If SMTP_HOST is not set, the app writes the message, code included, to its log instead. That is how the local setup works. See Auth and sessions.

Email login

curl -X POST http://localhost:5008/api/players/login/email \
  -H "Content-Type: application/json" \
  -d '{"email":"player@example.com","password":"at-least-8-chars"}'
# {"id":"<player-id>","displayName":"Sir Bob","token":"<token>","expiresAt":"..."}
Status When
200 The player and a fresh token
400 Missing or malformed email, or missing password
401 Wrong password or unknown email — identical body, so it can't be used to find out which emails exist
429 More than 5 attempts per minute from one IP

Request bodies (admin-gated endpoints)

Endpoint Fields
POST /api/players optional displayName (same rules as above). The player gets no credentials, so it can't sign in: those only come from register and link/email
POST /api/characters playerId (GUID of an existing player), name (1-50 characters, no control characters)
POST /api/events playerId (GUID of an existing player), eventType (1-100 characters), data (a string holding valid JSON, up to 10,000 bytes)

Only those fields are read. The id and the timestamp are always set by the server, and anything else you send (an id, a nested player, a timestamp) is ignored. A bad body returns 400 with { "error": "..." }, and a playerId that does not exist returns 400 { "error": "no such player" }.

Responses are small records, not the stored rows: a character is { id, playerId, name } and an event is { id, playerId, eventType, timestamp, data }.

Worked example

curl -b cookies.txt -X POST http://localhost:5008/api/players \
  -H "Content-Type: application/json" \
  -d '{"displayName":"Test Player"}'
# {"id":"<player-id>","displayName":"Test Player"}

curl -b cookies.txt -X POST http://localhost:5008/api/characters \
  -H "Content-Type: application/json" \
  -d '{"playerId":"<player-id>","name":"Hero"}'

curl -b cookies.txt -X POST http://localhost:5008/api/events \
  -H "Content-Type: application/json" \
  -d '{"playerId":"<player-id>","eventType":"level_up","data":"{\"level\":2}"}'

Overview stats

GET /api/admin/stats (any admin) feeds the admin UI's Overview page, PlayFab's Title Overview in miniature:

{
  "generatedAt": "2026-11-17T16:00:00Z",
  "totalPlayers": 19,
  "uniqueUsers": { "last24h": 4, "previous24h": 2, "last30Days": 11, "previous30Days": 0 },
  "newUsers":    { "last24h": 4, "previous24h": 1, "last30Days": 19, "previous30Days": 0 },
  "logins":      { "last24h": 6, "previous24h": 2, "last30Days": 31, "previous30Days": 0 },
  "days": [{ "endsAt": "2026-10-19T16:00:00Z", "uniqueUsers": 0, "newUsers": 0, "logins": 0 }, "… 30 in all, oldest first"]
}
  • A day is a rolling 24 hours counted back from generatedAt, not a calendar day, so the numbers mean the same in every timezone. days[29] is the last 24 hours.
  • A login is a player session being issued, so register counts as one too.
  • A unique user is a player with at least one session in the period. Across a period it is counted on its own (one player on two days is one user), so it is not the sum of the days.
  • A new user is a player whose id (a UUIDv7) was made in the period; there is no created_at column.
  • Each previous… figure is the period just before, for the Change column.

Player data, as an admin

What the admin UI's player page uses. {id} must be a GUID, so these routes can never catch one of the public sign-in paths (register, login/device...).

A player in the list and from GET /api/players/{id} has createdAt, read from the id itself (player ids are UUIDv7, which start with their creation time; null if an id isn't one), and lastLoginAt, the newest session (null if they never signed in). GET /api/players/{id} adds accounts: [{ provider, linkedAt, verified }]; verified matters only for an email, and the address itself is never included.

GET /api/players/{id}/data always answers with all three tiers, in this order, even when one is empty:

{
  "tiers": [
    { "tier": "ClientWritable", "entries": [] },
    { "tier": "ReadOnly", "entries": [{ "key": "Xp", "value": "1200", "updatedAt": "2026-11-16T09:12:00Z" }] },
    { "tier": "Internal", "entries": [] }
  ]
}

POST /api/players/{id}/data?tier=ReadOnly takes the same body and gives the same answer as the game server's write: { data: { key: value }, keysToRemove: [key] } → { updated: n }. It is held to exactly the same rules (keys, 16 KB values, 10 changes a request, 100 keys a tier, a key not in both lists) through PlayerDataRules.TryReadChanges, and an admin may write any tier, Internal included. Each successful edit is logged under the AdminActions category with the admin's username and the keys set and removed, never the values.

Status When
200 Read, or the edit was made
400 A bad tier, key or value, or a limit, with the same messages as the game server's route; nothing is written
401 Not signed in as an admin (a player token or server key doesn't count)
404 No such player

Error shapes

Three shapes, and a client has to handle all of them:

Shape Which responses
{ "error": "message" } 400, 401, 403, 404, 409, and 500 (a generic message: details go to the log)
Empty body 204 (success), and 429
404 with empty body, Server: Caddy Caddy's default-deny, not the app at all

A path under /api that no route matches returns 404 with { "error": "no such route" }, including a known path called with the wrong method. An unexpected server error, such as anything else that goes wrong (a database failure, say), returns 500 with { "error": "something went wrong on the server" }.

web/src/api.ts is a working reference for handling these in one place.

Malformed JSON returns 400

From the framework's model binding, before any handler runs.

What does not exist

Asked for often enough to be worth listing:

Wanted Status
GET /api/players/{id} for characters or events No — only players have a single-item route
Filtering a player's characters or events No
Paging No — every list returns the whole table
PUT / PATCH / DELETE on game data No
Player logout / revoking a player session No — tokens last 30 days
Player access to characters and events No — a player token only unlocks the email routes
Unlinking or changing an email, changing a password while signed in No
An audit log No table exists — admin player-data edits are only logged
Admin password change / reset No (players have a reset by email)
Restoring a deactivated admin No, by design