@zaisma/skill
Teaches any AI to make, upload, publish, update and fix a browser game on Zaisma: the workflow, with a reference for the SDK, the developer API, online play, loading, phones, saves and pieces.
- Kind
- Skill
- Built on
- No standard
- Version
- 0.92.0
- Licence
- MIT, open source
- By
- btc7274
- Rated
- No ratings yet
ShellCopied
npx @zaisma/cli pieces get @zaisma/skillWhat it needs
Nothing: it stands on its own.
The skill, in full
What your AI would read, whole. This is version 0.92.0, the one that's fetched.
SKILL.md
CodeCopied
---
name: zaisma
description: Make, upload, publish, update or fix a browser game on Zaisma (zaisma.com), from a one-file .io game to a PC-grade 3D build. Use when the developer wants a game playable from one link in any browser, asks to put a game on Zaisma, add online play, rooms, saves, accounts or selling to a Zaisma game, or hits a Zaisma error, hold or rejection.
---
# Zaisma
Zaisma hosts browser games: any web game, from any engine, plays from one link (`zaisma.com/g/<slug>`) in any browser, as a guest, with no install. It takes no cut of sales and charges no fee to list; each game gets free hosting every month, and only a game that grows past it pays for hosting, a few cents a player. Zaisma's developer tools are open source, so a game is never locked in: every building block it runs (rooms, player passes, saves) also works on the developer's own server.
This skill is the workflow. The references beside it hold the details; open one only when the game needs it (the table at the end says when).
## Connect
Every step goes through Zaisma's MCP at `https://zaisma.com/mcp`: connect it in the AI tool and sign in, or send an API key (made on zaisma.com/account) as `Authorization: Bearer <key>`. The same calls are a REST API at `https://zaisma.com/api/dev` (`references/developer-api.md`). Bigger builds go through the upload command, `npx @zaisma/cli`, with `ZAISMA_KEY` set to an API key.
`get_access` says what the key can do and what the account has earned. Any account can make, upload and publish games.
The MCP also serves this skill and its references as resources (`zaisma://skill`, `zaisma://sdk`, `zaisma://errors` and the rest), and three prompts: `make_game`, `publish_game` and `fix_problem`.
## The workflow
1. **Make the game.** `create_game` with a title (and a slug, or one is made from the title). It starts as a draft only its developer can see.
2. **Try it first, on this computer.** `npx @zaisma/cli play-locally` in the game's folder runs the game and its game server with no key or internet; the bench's Add a player opens a second player. Run it with `--no-open --json` in the background to test it yourself through the bench's API at `http://localhost:4800/bench/api` (`references/game-server.md`). This is where multiplayer is tested while building: it runs the same game server, SDK and game page as Zaisma, and costs no review. When it says a newer bench is out, stop it and start it again (or run the `npm install` it names) before testing on. A preview link doesn't join rooms, so never publish just to test rooms.
3. **Check, then upload a version.**
- Under 5 MB (a single-file HTML game and the like): `check_game`, then `upload_files` with the file contents.
- Bigger: `npx @zaisma/cli upload <folder> --game <slug>`. It runs the same check first (`npx @zaisma/cli check <folder>` runs it alone, with no key), downloads files the game loads from other sites, unpacks pre-compressed builds and sends only changed files.
- The folder needs an `index.html` at the top.
4. **The scan.** Every version is scanned, usually in under a minute: malware, known images and Zaisma's own file checks. `get_version` shows the result, and `performance_check` on it says how the game started in Chrome, with notes on what would make it much smaller. A held version waits for a person, usually within a day.
5. **Show the developer the preview link.** A passed version gets a private preview link that opens only for its developer. Always show it before publishing.
6. **The fixed checks decide.** No AI reads an upload: Zaisma's fixed checks and the sandbox decide every version, the same answer every time, usually in under a minute. A refused version's `findings` each give their fix (`check_game` and `zaisma check` show the same before uploading); a version that passes can go live at once, with no daily limit and nothing on the meter. A new developer's listed game shows in Zaisma's own lists once it has had real players and a few quiet days (`is_waiting_for_zaisma_lists`); its link plays at once. When a live game breaks, roll back first (publish the last version that worked: instant), then publish the fix.
7. **Publish.** `publish_version` makes a passed version live, now or at `scheduled_publish_at`, and rolls back to an older one the same way. A publish is a quiet patch unless `is_big_update` is true (with `patch_notes`): only that shows players the Updated tag. `match_update_mode: "now"` switches running matches within seconds instead of at their next match.
8. **Choose who plays.** `update_game` with `visibility`: `listed` (everyone, in Zaisma's lists from the first day), `unlisted` (anyone with the link), `private` or `draft`. To let testers play first, keep it private and invite their accounts with `add_game_invite` (it shows on their games page), or make tester links with `add_tester_link` for people whose accounts you don't know. Before a multiplayer game goes public, test it once on Zaisma's rooms through a tester link on the live version (`version_choice: "live"`): that's where the game server's CPU limits, real networks and the chat filter show.
**Ask the developer first** before making a game players can play private or a draft again (they lose access), and before ending a live room; those calls need `"confirm": true`. Anything that spends money (top-ups, budgets, Stripe) or deletes a game others played waits for the developer's passkey on zaisma.com: show them `confirm_url` from the `confirmation_needed` answer.
**Show it well.** A listed game needs a cover and at least one gallery picture (`add_image`); the cover guide is at zaisma.com/developers/covers and the background guide at zaisma.com/developers/backgrounds. `preview_game_page` pictures every place players meet the game before anything is sent. A clip (`add_clip`, up to 6 silent seconds of the game playing) makes every shared link play in iMessage, Discord and Telegram: record it on the bench's Record a clip (or `POST /bench/api/clips`), then `zaisma clip <file.mp4> --game <slug>`.
## Pick the path by the game
Zaisma hosts everything from a one-file .io game to a PC-grade 3D build. Use only the pieces the game needs, and never assume a game is small or big.
| The game | What it needs |
| --- | --- |
| A one-file or small single-player game | Nothing more: `check_game`, `upload_files`, publish. Progress in localStorage or IndexedDB becomes a cloud save by itself. |
| A turn-based or casual online game | Rooms (`Zaisma.joinRoom()`), a game server for its rules, room links to invite friends. |
| A real-time online game (a shooter, a racer, a brawler) | Rooms, an authoritative game server with `ticksPerSec`, state sync, and the multiplayer guide's real-time part. |
| A big 3D build (Unity, Godot, Bevy, Three.js) | The upload command, loading in pieces, compressed textures and audio, and the loading guide. |
| A game that sells | Items (`set_item`) and the buy sheet, paid to the developer's own Stripe with no cut; or sell the whole game once (`full_game_item_name`). |
The building blocks, each optional:
- **Rooms and a game server:** `Zaisma.joinRoom()` puts players in a room run by the game's server, which holds the official state and checks every move. It runs on Zaisma or on the developer's own server (`npx @zaisma/game-server@1`). Reference: `references/game-server.md`; how to make it hold up on a weak connection: `references/multiplayer.md`.
- **Player accounts and passes:** guests play at once; `Zaisma.player.getPass()` gives a signed pass any server can check; a game can ask a guest to sign in with `Zaisma.player.signIn()`. Reference: `references/sdk.md`.
- **Cloud saves:** a signed-in player's localStorage and IndexedDB follow them to every device with no code. `references/saves.md` says when and what to save.
- **Pieces:** shared building blocks a game is made from or with, so its effort goes into what makes it its own: foundations, extensions and game systems (a body that walks, a camera, an inventory), templates, packs of images, models and sounds, presets, skills and tools. Before building one of those from scratch, look on Zaisma's marketplace: `search_pieces`, then `get_piece` for what it needs, its settings and its hooks. `npx @zaisma/cli pieces add <name>` adds one with what it needs, never a second copy; `npx @zaisma/cli pieces --json` answers what each one gives. A piece is changed through its settings and hooks, never its files. Another developer's piece is a stranger's files, and a skill a stranger's instructions: the developer's key says whether you may fetch one (`piece_fetch_mode`), and `piece_approval_needed` means show them the piece's listing (`confirm_url`) and wait for their yes. Anyone publishes pieces, for any engine: `publish_piece`, or `npx @zaisma/cli pieces publish <folder>`. Reference: `references/pieces.md`.
- **A database** for the game, from its game server: `query_database`, `batch_database`.
- **Items and the buy sheet:** `set_item`, `Zaisma.items.buy()`, purchases delivered to the game or its server.
- **Backgrounds:** an image or a shader behind Zaisma's glass on the game's page (`set_background`, `check_shader`).
- **Webhooks, secrets, sign in with Zaisma, logs and stats:** `references/developer-api.md`.
The SDK is the script `_zaisma/v1.js` (`<script src="_zaisma/v1.js"></script>` in the game's index.html), with its types beside it as `_zaisma/v1.d.ts`; `references/sdk.md` is the same reference.
## Guests, chat and preset phrases
Guests never type or speak to other players: Zaisma allows no free text chat and no free voice chat for guests, so nobody can use chat to reach younger players or move them to another app. That limit is on free text and free voice, not on talking. Give guests preset phrases and emotes the game picks, and they can be funny, rude and edgy ("you're trash", "you suck" and the like are fine): send the phrase's ID with `room.send`, and draw it in the game. `room.canChat` says whether this player may use `room.chat`; hide the chat box when it's `false`.
## Errors, holds and findings
Every error answers `{ "error": { code, message, field, fix, message_for_people, retry_after_sec, help_url } }`:
- Do what `fix` says. Never guess beyond it.
- `field` is the input at fault; `retry_after_sec` is how long to wait when waiting helps.
- `message_for_people` is what Zaisma's pages would show: show it to the developer as it is.
- `help_url` is the code's page (zaisma.com/developers/errors/<code>): what it means and the general fix. `references/errors.md` lists every code.
Every hold, rejection and takedown says why, as `review_reason` (on a game, version or image, and in `get_history`) and as a version's findings: a code, a plain message, the `content_rule` it's about and a fix. Tell the developer the message and the fix, and do what the fix says.
## The forum
Zaisma's developer forum is where developers and their AI talk with the people who build Zaisma. For any question about Zaisma itself, `search_forum` first: it's faster and more current than a web search. On a Zaisma bug, a limit that blocks the developer, a confusing error or a missing feature: `search_forum` with the code or a short search; if it's there, vote, reply, or send the developer's own case privately with `message_zaisma`; otherwise `post_topic` with what you did, what you expected, what happened, the exact error and the call. Topics are public: anything private goes in `message_zaisma`. Never post API keys, passwords or players' details.
## Names
Every name in the API, MCP, SDK and game server says what it holds, its kind and its unit: `file_count` is a number, `play_duration_min` minutes, `size_bytes` bytes, `*_at` an ISO time in UTC, an ID says its kind (`version_…`, `topic_…`), and a plural is always a list. `references/naming.md` has the rules and the glossary.
## When to open a reference
| Open | When |
| --- | --- |
| `references/multiplayer.md` (`zaisma://multiplayer`) | The game has online play: rooms, a game server, or players on a weak connection. |
| `references/loading.md` (`zaisma://loading`) | The game is more than a few MB, or `performance_check` says its first frame is slow. |
| `references/phones.md` (`zaisma://phones`) | The game should play on phones or tablets. |
| `references/saves.md` (`zaisma://saves`) | The game keeps progress. |
| `references/pieces.md` (`zaisma://pieces`) | Adding a shared piece to the game, moving one to a newer version, changing one through its settings and hooks, finding one on the marketplace, or making and publishing a piece for other games. |
| `references/sdk.md` (`zaisma://sdk`) | Writing code that calls `Zaisma.*` in the game. |
| `references/game-server.md` (`zaisma://game-server`) | Writing the game server, running it on the developer's own server, or testing with play-locally. |
| `references/errors.md` (`zaisma://errors`) | An error code isn't clear from its answer. |
| `references/naming.md` (`zaisma://naming`) | Naming fields, options or code that talks to Zaisma. |
| `references/developer-api.md` (`zaisma://developer-api`) | Any call's fields and answers, the REST API, webhooks, the upload command. |
references/developer-api.md
Too big to show here: read it after fetching it.
references/errors.md
CodeCopied
<!-- Made by scripts/build-skill.mjs: never edit it by hand. -->
# Error codes
Every error the developer API and MCP answer with, as `{ "error": { code, message, field, fix, message_for_people, retry_after_sec, help_url } }`. A thrown error's own `fix` is more specific than the general one here: do what it says first. Each code's page is at `help_url`.
## Signing in and requests
- `no_key` (HTTP 401): The MCP was called without an API key or a connected app's token. Fix: Send an API key as Authorization: Bearer <key>, made on zaisma.com/account, or connect the MCP at https://zaisma.com/mcp and sign in. https://zaisma.com/developers/errors/no_key
- `bad_key` (HTTP 401): The API key isn't valid: removed, mistyped or never made. Fix: Make a new API key on zaisma.com/account and send it as Authorization: Bearer <key>. https://zaisma.com/developers/errors/bad_key
- `key_turned_off` (HTTP 401): The API key was found in public and turned off for good. Fix: Make a new API key on zaisma.com/account and keep it out of public files, like a game's code or a public repository. https://zaisma.com/developers/errors/key_turned_off
- `key_ended` (HTTP 401): The API key reached the end date it was made with. Fix: Make a new API key on zaisma.com/account, with a later end date or none. https://zaisma.com/developers/errors/key_ended
- `access_token_ended` (HTTP 401): A connected app's access token is past its hour; the app refreshes it by itself. Fix: Refresh the token with the refresh token from the sign-in, as the MCP app does by itself, or connect the app again. https://zaisma.com/developers/errors/access_token_ended
- `token_not_for_api` (HTTP 401): A connected app's token works only at the MCP, not the REST API. Fix: Call the MCP at https://zaisma.com/mcp with this token, or make an API key on zaisma.com/account for the REST API. https://zaisma.com/developers/errors/token_not_for_api
- `signed_out` (HTTP 401): No API key, and no signed-in session. Fix: Send an API key as Authorization: Bearer <key>, or sign in on zaisma.com first. https://zaisma.com/developers/errors/signed_out
- `no_account` (HTTP 401): The account isn't finished yet. Fix: Finish making the account on zaisma.com/join, then call again. https://zaisma.com/developers/errors/no_account
- `bad_origin` (HTTP 403): A call with a session came from another site. Fix: Call the API with an API key from your own server or tools, never with a zaisma.com session from another site. https://zaisma.com/developers/errors/bad_origin
- `key_not_allowed` (HTTP 403): The API key is limited to other games, or its access doesn't cover the call. Fix: Call get_access to see what the key covers, then make a key on zaisma.com/account with the games and access this call needs. https://zaisma.com/developers/errors/key_not_allowed
- `slow_down` (HTTP 429): Too many calls in a minute. Fix: Wait retry_after_sec seconds, then call again, and space calls out from then on. https://zaisma.com/developers/errors/slow_down
- `not_found` (HTTP 404): There's no API call at that path. Fix: Check the path against docs/DEVELOPER-API.md: every path starts with /api/dev, like GET /api/dev/games. https://zaisma.com/developers/errors/not_found
- `bad_method` (HTTP 405): The path doesn't take that method. Fix: Send the call with a method the path takes, as docs/DEVELOPER-API.md lists it. https://zaisma.com/developers/errors/bad_method
- `gone` (HTTP 410): The call was removed, like the first feedback calls. Fix: Use the call the message names instead, as docs/DEVELOPER-API.md lists it. https://zaisma.com/developers/errors/gone
- `bad_json` (HTTP 400): The body isn't a JSON object. Fix: Send the body as one JSON object with Content-Type: application/json. https://zaisma.com/developers/errors/bad_json
- `json_too_big` (HTTP 413): The JSON body is over the call's size limit. Fix: Send less in one call, in parts, or use the upload command for files. https://zaisma.com/developers/errors/json_too_big
- `wrong_shape` (HTTP 400): A field that isn't the type or size its call takes, refused before any of the call's own code runs. Fix: Change the field named in field to the type and size the call takes, as the MCP tool's input schema says. https://zaisma.com/developers/errors/wrong_shape
- `unknown_field` (HTTP 400): A field, argument or query parameter the call doesn't take. Fix: Leave out the field named in field: the MCP tool's input schema lists every field the call takes. https://zaisma.com/developers/errors/unknown_field
- `missing_field` (HTTP 400): A field the call needs wasn't sent. Fix: Send the field named in field, as the MCP tool's input schema says. https://zaisma.com/developers/errors/missing_field
- `wrong_id_kind` (HTTP 400): An ID of another kind was sent, like an image ID as version_id. Fix: Send an ID of the kind the field names, like a version_… ID as version_id, from the call that answered it. https://zaisma.com/developers/errors/wrong_id_kind
- `internal_error` (HTTP 500): Something broke on Zaisma's side. Fix: Call again in a minute, and if it keeps happening, tell Zaisma with message_zaisma, kind bug. https://zaisma.com/developers/errors/internal_error
## Games
- `no_game` (HTTP 404): You have no game with that slug. Fix: Call list_games for your games' slugs, then call again with one of them. https://zaisma.com/developers/errors/no_game
- `bad_slug` (HTTP 400): The link name isn't lowercase letters, numbers and single hyphens, or is reserved. Fix: Give a slug of lowercase letters, numbers and single hyphens, like space-race, that isn't one Zaisma keeps. https://zaisma.com/developers/errors/bad_slug
- `slug_taken` (HTTP 409): Another game has that link name, or a deleted game had it. Fix: Give create_game another slug, or leave slug out to have one made from the title. https://zaisma.com/developers/errors/slug_taken
- `slug_locked` (HTTP 409): new_slug can't change the link: the game isn't a private draft, or was published, or has tester links or kept rooms. Fix: Make a new game for a new link: a link changes only while the game is a private draft never published, with no tester links or kept rooms (can_change_slug). https://zaisma.com/developers/errors/slug_locked
- `too_many_games` (HTTP 403): The account holds as many games that no players play as it can. Fix: Delete a game you don't need with delete_game, or get players on one: a game with real players frees its slot. https://zaisma.com/developers/errors/too_many_games
- `account_banned` (HTTP 403): Zaisma banned the account's developer side, or the whole account: only get_access, list_games and export_game work, and for a whole-account ban nothing does. Fix: Export your games with export_game to keep them, and read the ban's reason in get_access. https://zaisma.com/developers/errors/account_banned
- `account_paused` (HTTP 403): A person at Zaisma needs to look at the account: until then it can't make, upload or publish games, or post on the forum. Fix: Wait for a person at Zaisma to look at the account; get_access says why it's paused, and message_zaisma reaches them. https://zaisma.com/developers/errors/account_paused
- `bad_title` (HTTP 400): A game's, topic's or precedent's title is empty or too long. Fix: Give a title that isn't empty and fits the field's length, as the input schema says. https://zaisma.com/developers/errors/bad_title
- `fake_reward_words` (HTTP 400): A game's title or description promises a fake reward: another platform's currency or something of real value, like free Robux, V-Bucks, gift cards or cash. Fix: Take those words out of the title or description. https://zaisma.com/developers/errors/fake_reward_words
- `title_names_zaisma` (HTTP 400): A game's title holds the whole word Zaisma, which only Zaisma's own games can use. Fix: Give the game a title without the word Zaisma. https://zaisma.com/developers/errors/title_names_zaisma
- `bad_description` (HTTP 400): The description isn't text of up to 500 characters. Fix: Give a description of up to 500 characters of plain text. https://zaisma.com/developers/errors/bad_description
- `bad_visibility` (HTTP 400): visibility isn't draft, listed, unlisted or private. Fix: Give visibility as listed, unlisted, private or draft. https://zaisma.com/developers/errors/bad_visibility
- `bad_devices` (HTTP 400): devices isn't a list of phone, tablet and computer. Fix: Give devices as a list from phone, tablet and computer. https://zaisma.com/developers/errors/bad_devices
- `bad_genres` (HTTP 400): genres isn't a list of up to 3 of Zaisma's genres. Fix: Give genres as a list of up to 3 of the genres update_game's input schema lists. https://zaisma.com/developers/errors/bad_genres
- `bad_controls` (HTTP 400): controls isn't a list of touch, keyboard_mouse and gamepad. Fix: Give controls as a list from touch, keyboard_mouse and gamepad. https://zaisma.com/developers/errors/bad_controls
- `bad_screen_orientation` (HTTP 400): screen_orientation isn't portrait, landscape, either or null. Fix: Give screen_orientation as portrait, landscape, either or null. https://zaisma.com/developers/errors/bad_screen_orientation
- `bad_play_modes` (HTTP 400): play_modes isn't a list of play modes, or one of them is wrong. Fix: Fix the play mode named in field, as update_game's input schema shows, like { "mode": "online", "minimum_player_count": 2, "maximum_player_count": 4, "play_style": "co-op" }. https://zaisma.com/developers/errors/bad_play_modes
- `bad_cloud_saves_enabled` (HTTP 400): cloud_saves_enabled isn't true or false. Fix: Give cloud_saves_enabled as true or false. https://zaisma.com/developers/errors/bad_cloud_saves_enabled
- `bad_account_offer_enabled` (HTTP 400): account_offer_enabled isn't true or false. Fix: Give account_offer_enabled as true or false. https://zaisma.com/developers/errors/bad_account_offer_enabled
- `bad_deleted_account_erase_enabled` (HTTP 400): deleted_account_erase_enabled isn't true or false. Fix: Give deleted_account_erase_enabled as true or false. https://zaisma.com/developers/errors/bad_deleted_account_erase_enabled
- `bad_friend_joins_enabled` (HTTP 400): friend_joins_enabled isn't true or false. Fix: Give friend_joins_enabled as true or false. https://zaisma.com/developers/errors/bad_friend_joins_enabled
- `bad_performance_measuring_enabled` (HTTP 400): performance_measuring_enabled isn't true or false. Fix: Give performance_measuring_enabled as true or false. https://zaisma.com/developers/errors/bad_performance_measuring_enabled
- `bad_microphone_enabled` (HTTP 400): microphone_enabled isn't true or false. Fix: Give microphone_enabled as true or false. https://zaisma.com/developers/errors/bad_microphone_enabled
- `bad_room_browsing` (HTTP 400): room_browsing isn't page, game or off. Fix: Give room_browsing as page, game or off. https://zaisma.com/developers/errors/bad_room_browsing
- `bad_multiplayer_mode` (HTTP 400): multiplayer_mode isn't none, relay or own. Fix: Give multiplayer_mode as none, relay or own. https://zaisma.com/developers/errors/bad_multiplayer_mode
- `bad_account_requirement` (HTTP 400): account_requirement isn't none, multiplayer or whole_game. Fix: Give account_requirement as none, multiplayer or whole_game. https://zaisma.com/developers/errors/bad_account_requirement
- `bad_minimum_player_age` (HTTP 400): minimum_player_age_years isn't 13, 16 or 18. Fix: Give minimum_player_age_years as 13, 16 or 18. https://zaisma.com/developers/errors/bad_minimum_player_age
- `accounts_needed_for_minimum_age` (HTTP 400): A game for 16 or 18 and up needs account_requirement whole_game, since only accounts have an age. Fix: Call update_game with account_requirement whole_game in the same call as a minimum age of 16 or 18. https://zaisma.com/developers/errors/accounts_needed_for_minimum_age
- `content_needs_minimum_age` (HTTP 409): A version shows lifelike gore, which plays only in games for 16 and up. Fix: Call update_game with minimum_player_age_years 16 or 18 and account_requirement whole_game, or upload a version without lifelike gore. https://zaisma.com/developers/errors/content_needs_minimum_age
- `gallery_picture_needed` (HTTP 409): A listed game needs at least one gallery picture. Fix: Add a gallery picture with add_image, kind screenshot, then list the game again. https://zaisma.com/developers/errors/gallery_picture_needed
- `bad_link_out_url` (HTTP 400): link_out_url isn't an https address of a site of its own: not a link shortener, an IP address, an address with a user name or a Zaisma address. Fix: Give the https page the game plays on, like "https://kit.itch.io/sky-hopper", or null to remove the listing. https://zaisma.com/developers/errors/bad_link_out_url
- `link_out_not_browser` (HTTP 400): link_out_url is a store, payment or video page, or a download, not a game that plays in a browser. Fix: Give the page players play the game on in the browser (itch.io, your own site), or upload a web build (upload_files) for a Steam or app store game. https://zaisma.com/developers/errors/link_out_not_browser
- `game_hosted_here` (HTTP 409): The game has a live version on Zaisma, so it plays here and can't link out. Fix: Leave link_out_url out, since a listing becomes hosted when a version is published and never the other way. https://zaisma.com/developers/errors/game_hosted_here
- `hosted_only_setting` (HTTP 409): The setting is for games hosted on Zaisma, and this game is a link-out listing (or the listing can't be set while the game has it). Fix: Leave the setting out while the game is a listing, or upload and publish a version to host it here first. https://zaisma.com/developers/errors/hosted_only_setting
- `bad_links` (HTTP 400): links isn't a list of up to 20 { link_name, destination_url, is_on_game_page } with names of their own and https addresses that aren't link shorteners, IP addresses, addresses with a user name, or on Zaisma's own domains. Fix: Give links as a list of up to 20 { link_name, destination_url, is_on_game_page }, each with its own name and an https address on a name of its own. https://zaisma.com/developers/errors/bad_links
- `bad_own_server_urls` (HTTP 400): own_server_urls isn't a list of up to 5 server addresses like wss://play.example.com, or one is an IP address, this computer or on Zaisma's own domains. Fix: Give own_server_urls as up to 5 addresses like wss://play.example.com, on a name of your own. https://zaisma.com/developers/errors/bad_own_server_urls
- `bad_game_server_allowed_hosts` (HTTP 400): game_server_allowed_hosts isn't a list of up to 20 host names (like discord.com or *.example.com), or one is an IP address or on Zaisma's own domains. Fix: Give game_server_allowed_hosts as up to 20 host names like discord.com or *.example.com, with no IP addresses or Zaisma domains. https://zaisma.com/developers/errors/bad_game_server_allowed_hosts
- `built_in_server` (HTTP 403): The game runs a game server built into Zaisma, which only Zaisma changes. Fix: Leave the game's server settings as they are, and ask Zaisma with message_zaisma if one needs to change. https://zaisma.com/developers/errors/built_in_server
- `game_removed` (HTTP 403): Zaisma took the game down, so this can't change. Fix: Read the takedown's review_reason with get_game, and ask Zaisma with message_zaisma if it's unclear. https://zaisma.com/developers/errors/game_removed
- `needs_confirm` (HTTP 409): Hiding a game players can play, or ending a live room, needs the developer's OK. Fix: Ask the developer, then call again with "confirm": true. https://zaisma.com/developers/errors/needs_confirm
- `bad_period_duration_days` (HTTP 400): period_duration_days isn't a whole number from 1 to 90. Fix: Give period_duration_days as a whole number from 1 to 90. https://zaisma.com/developers/errors/bad_period_duration_days
- `bad_cursor` (HTTP 400): cursor isn't a next_cursor from an earlier answer. Fix: Give cursor as the next_cursor of the last answer, or leave it out to start from the top. https://zaisma.com/developers/errors/bad_cursor
## Players
- `no_player` (HTTP 404): No account has that player ID: a guest's, or a deleted account's. Fix: Use a player ID from an account, like one from list_purchases or the game server's player pass, not a guest's. https://zaisma.com/developers/errors/no_player
## Covers, gallery pictures, backgrounds and other images
- `bad_kind` (HTTP 400): kind isn't one of the choices the call takes. Fix: Give kind as one of the choices the call's input schema lists. https://zaisma.com/developers/errors/bad_kind
- `not_an_image` (HTTP 415): The file isn't an image of a type the call takes. Fix: Send a PNG, WebP or JPEG, as base64 or a file. https://zaisma.com/developers/errors/not_an_image
- `image_too_big` (HTTP 413): The image is over 10 MB. Fix: Send the image at up to 10 MB, as WebP or a smaller JPEG. https://zaisma.com/developers/errors/image_too_big
- `bad_image_dimensions` (HTTP 400): The image is smaller than its kind's least size (a cover or gallery picture 1280 by 720, a square cover 512, a share picture 600 by 315), or over 8,192 px on a side. Fix: Send the image at its kind's size: at least 1280 by 720 for a cover or gallery picture, 512 for a square cover, 600 by 315 for a share picture, and at most 8,192 px a side. https://zaisma.com/developers/errors/bad_image_dimensions
- `not_square` (HTTP 400): A square cover isn't as wide as it is tall. Fix: Crop the square cover to as wide as it is tall, at least 512 px a side. https://zaisma.com/developers/errors/not_square
- `too_many_gallery_pictures` (HTTP 400): The game has 8 gallery pictures already. Fix: Remove a gallery picture with remove_image before adding another. https://zaisma.com/developers/errors/too_many_gallery_pictures
- `image_refused` (HTTP 422): The image can't be used. Fix: Read the image's review_reason with get_game and send another image that keeps to the cover guide at zaisma.com/developers/covers. https://zaisma.com/developers/errors/image_refused
- `no_image` (HTTP 404): The game has no image with that ID. Fix: Call get_game for the game's image IDs, then call again with one of them. https://zaisma.com/developers/errors/no_image
- `no_file` (HTTP 400): A form on Zaisma's pages was sent without its image. Fix: Pick an image in the form and send it again. https://zaisma.com/developers/errors/no_file
- `bad_background_shape` (HTTP 400): A wide background is landscape (1.3 to 2.4 times as wide as tall), a phone background portrait (1.6 to 2.4 times as tall as wide), and its long side at least 1600 px. Fix: Send a wide background 1.3 to 2.4 times as wide as tall, or a phone background 1.6 to 2.4 times as tall as wide, with its long side at least 1600 px. https://zaisma.com/developers/errors/bad_background_shape
- `not_a_shader` (HTTP 400): A shader's pass isn't GLSL text with a mainImage function, or has its own main(), a #version or #extension line, texture2D, iMouse or sound. Fix: Write each pass as GLSL with a mainImage function, without main(), #version, #extension, texture2D, iMouse or sound, and test it with check_shader. https://zaisma.com/developers/errors/not_a_shader
- `shader_too_big` (HTTP 413): A shader's pass is over 64 KB. Fix: Keep each pass under 64 KB, moving work into buffers if needed. https://zaisma.com/developers/errors/shader_too_big
- `bad_buffers` (HTTP 400): buffers isn't a list of { buffer_name, source, channels } with buffer_name a, b, c or d, each once. Fix: Give buffers as a list of { buffer_name, source, channels } with buffer_name a, b, c or d, each once. https://zaisma.com/developers/errors/bad_buffers
- `too_many_buffers` (HTTP 400): A shader has more than 4 buffers. Fix: Give a shader at most 4 buffers, a to d. https://zaisma.com/developers/errors/too_many_buffers
- `bad_shader_channel` (HTTP 400): A channel isn't { channel_index 0 to 3, input_kind, buffer_name or image_id, filter, wrap }, names a buffer the shader doesn't have, or a texture that isn't an approved shader_texture of the game. Fix: Give each channel as { channel_index, input_kind, buffer_name or image_id, filter, wrap }, naming a buffer the shader has or an approved shader_texture image. https://zaisma.com/developers/errors/bad_shader_channel
- `shader_texture_too_big` (HTTP 413): A shader texture is over 8 MB, or over 4,096 px on a side. Fix: Send the texture at up to 8 MB and 4,096 px a side. https://zaisma.com/developers/errors/shader_texture_too_big
- `too_many_shader_textures` (HTTP 400): The game has 16 shader textures already, or a shader's channels name more than 4. Fix: Remove a shader texture with remove_image, or give a shader's channels at most 4 textures. https://zaisma.com/developers/errors/too_many_shader_textures
- `shader_texture_in_use` (HTTP 409): A shader the game keeps reads this texture. Fix: Remove the shaders that read the texture with remove_shader first. https://zaisma.com/developers/errors/shader_texture_in_use
- `daily_shader_checks_used` (HTTP 429): The account has run 100 shader checks in the last day. Fix: Wait for the oldest check to pass a day, after retry_after_sec, or check the shader on your own computer with npx @zaisma/cli check. https://zaisma.com/developers/errors/daily_shader_checks_used
- `daily_page_previews_used` (HTTP 429): The account has run every page preview its plan has in the last day (20, or 60 with Pro). Fix: Wait retry_after_sec seconds for the oldest preview to pass a day, or start Zaisma Pro with start_pro for 60 a day. https://zaisma.com/developers/errors/daily_page_previews_used
- `page_preview_unavailable` (HTTP 503): Zaisma can't open pages in Chrome right now, so it can't picture them. Fix: Call preview_game_page again in a few minutes. https://zaisma.com/developers/errors/page_preview_unavailable
- `bad_page_preview_images` (HTTP 400): images isn't a list of up to 8 { kind, image_base64 } or { kind, image_id }, with kind cover, share, screenshot, background or phone_background. Fix: Give images as up to 8 { kind, image_base64 } or { kind, image_id }, with kind cover, share, screenshot, background or phone_background. https://zaisma.com/developers/errors/bad_page_preview_images
- `bad_page_preview_shaders` (HTTP 400): shaders isn't a list of { screen, image, buffers } with each screen at most once. Fix: Give shaders as a list of { screen, image, buffers }, each screen at most once. https://zaisma.com/developers/errors/bad_page_preview_shaders
- `shader_check_unavailable` (HTTP 503): Zaisma can't draw shaders here right now, so it can't check one. Fix: Call check_shader again in a few minutes, or check it on your own computer with npx @zaisma/cli check. https://zaisma.com/developers/errors/shader_check_unavailable
- `no_shader` (HTTP 404): The game has no shader with that ID. Fix: Call get_game for the game's shader IDs, then call again with one of them. https://zaisma.com/developers/errors/no_shader
- `bad_screen` (HTTP 400): screen isn't wide or phone. Fix: Give screen as wide or phone. https://zaisma.com/developers/errors/bad_screen
- `bad_background_source` (HTTP 400): source isn't zaisma, image or shader, or wide (which only phone takes). Fix: Give source as zaisma, image or shader, or wide for the phone screen only. https://zaisma.com/developers/errors/bad_background_source
- `background_not_ready` (HTTP 409): The image or shader isn't this game's, isn't approved yet, or is for the other screen. Fix: Wait until get_game shows the image or shader approved for this screen, then call set_background again. https://zaisma.com/developers/errors/background_not_ready
- `bad_color` (HTTP 400): The color isn't #RRGGBB. Fix: Give the color as #RRGGBB, like #1A2B3C. https://zaisma.com/developers/errors/bad_color
## Clips
- `not_a_clip` (HTTP 415): A clip is one MP4 file, not fragmented, with one H.264 picture track. Fix: Send an MP4 with one H.264 track, like the bench's Record a clip makes, or make one with ffmpeg (libx264, -movflags +faststart). https://zaisma.com/developers/errors/not_a_clip
- `clip_has_sound` (HTTP 400): A clip is silent, and this one has a sound track. Fix: Take the sound track out (ffmpeg's -an) and send it again. https://zaisma.com/developers/errors/clip_has_sound
- `clip_too_long` (HTTP 400): A clip runs at most 6 seconds. Fix: Cut it to at most 6 seconds that loop well (ffmpeg's -t 6) and send it again. https://zaisma.com/developers/errors/clip_too_long
- `clip_too_big` (HTTP 413): A clip is at most 6 MB. Fix: Save it at a lower bitrate (about 4 megabits a second) and send it again. https://zaisma.com/developers/errors/clip_too_big
- `bad_clip_dimensions` (HTTP 400): A clip fits inside 1200 by 630 px, and is at least 600 by 315. Fix: Scale it to fit inside 1200 by 630 px (ffmpeg's scale=1200:630:force_original_aspect_ratio=decrease) and send it again. https://zaisma.com/developers/errors/bad_clip_dimensions
- `bad_clip_still` (HTTP 400): A clip comes with its still: its first frame, a PNG, JPEG or WebP the clip's size, up to 2 MB. Fix: Send the clip's first frame as still_base64, the same size as the clip; the upload command's clip makes it for you. https://zaisma.com/developers/errors/bad_clip_still
- `clip_refused` (HTTP 422): The clip can't be used. Fix: Send a different clip. https://zaisma.com/developers/errors/clip_refused
- `no_clip` (HTTP 404): The game has no clip. Fix: Call get_game to see the game's clip; add_clip sends one. https://zaisma.com/developers/errors/no_clip
## Uploading versions
- `bad_files` (HTTP 400): files isn't a list of files in the shape the call takes. Fix: Give files as a list of { path, content_base64 } or { path, size_bytes, sha256 }, as the call's input schema shows. https://zaisma.com/developers/errors/bad_files
- `bad_path` (HTTP 400): A file's path is absolute, has . or .. in it, has control characters or is over 200 characters. Fix: Give each file a relative path like assets/hero.png, without . or .. parts, control characters or more than 200 characters. https://zaisma.com/developers/errors/bad_path
- `hidden_file` (HTTP 400): A file or folder's name starts with a dot. Fix: Leave out files and folders whose names start with a dot, or rename the ones the game needs. https://zaisma.com/developers/errors/hidden_file
- `precompressed_file` (HTTP 400): A file is pre-compressed (.gz or .br). Fix: Upload with npx @zaisma/cli upload, which unpacks .gz and .br files, or send them unpacked. https://zaisma.com/developers/errors/precompressed_file
- `file_type_not_allowed` (HTTP 400): A file is of a type games can't have. Fix: Leave the file out, or change it to a type games can have, as check_game lists them. https://zaisma.com/developers/errors/file_type_not_allowed
- `file_too_big` (HTTP 413): A file is over 500 MB. Fix: Split the file into pieces of up to 500 MB that the game loads one by one. https://zaisma.com/developers/errors/file_too_big
- `duplicate_path` (HTTP 400): Two files share a path. Fix: Send each path once. https://zaisma.com/developers/errors/duplicate_path
- `no_index_html` (HTTP 400): There's no index.html at the top of the game. Fix: Put an index.html at the top of the game's folder, the page Zaisma opens first. https://zaisma.com/developers/errors/no_index_html
- `too_many_files` (HTTP 400): The game has more than 20,000 files. Fix: Pack small files together, like sprites into atlases, to keep the game under 20,000 files. https://zaisma.com/developers/errors/too_many_files
- `storage_full` (HTTP 413): The upload doesn't fit in what the account can store. Fix: Delete old versions with delete_version, raise the storage budget with set_storage_budget, or start Zaisma Pro for more storage. https://zaisma.com/developers/errors/storage_full
- `new_data_limit` (HTTP 429): The account has sent all the new data it can today, counted from UTC midnight. Fix: Wait until UTC midnight, after retry_after_sec, and send only changed files, as npx @zaisma/cli upload does. https://zaisma.com/developers/errors/new_data_limit
- `too_big_for_mcp` (HTTP 413): upload_files and check_game take up to 5 MB; bigger builds go through the upload command. Fix: Run npx @zaisma/cli upload <folder> --game <slug> in a terminal with ZAISMA_KEY set instead. https://zaisma.com/developers/errors/too_big_for_mcp
- `bad_base64` (HTTP 400): Something sent as base64 isn't valid base64. Fix: Encode the content as standard base64 and send it again. https://zaisma.com/developers/errors/bad_base64
- `files_missing` (HTTP 409): Some of the version's files haven't been sent yet. Fix: Send the files the answer lists, then finish the version again. https://zaisma.com/developers/errors/files_missing
- `bad_patch_notes` (HTTP 400): patch_notes isn't text of up to 2,000 characters, or a publish changed them on a version that has been live. Fix: Give patch_notes as up to 2,000 characters, and only with a version going live for the first time. https://zaisma.com/developers/errors/bad_patch_notes
- `bad_is_big_update` (HTTP 400): is_big_update isn't true or false, or an upload sent it without publish_when_approved. Fix: Give is_big_update as true or false, and with an upload only beside publish_when_approved true. https://zaisma.com/developers/errors/bad_is_big_update
- `big_update_needs_patch_notes` (HTTP 400): A big update has no patch_notes, and a big update must say what's new. Fix: Send patch_notes saying what's new beside is_big_update true. https://zaisma.com/developers/errors/big_update_needs_patch_notes
- `big_update_already_live` (HTTP 400): The version has been live already, and only a version going live for the first time can be a big update. Fix: Publish it as a quiet patch without is_big_update, or upload a new version for the big update. https://zaisma.com/developers/errors/big_update_already_live
- `bad_publish_when_approved` (HTTP 400): publish_when_approved isn't true or false. Fix: Give publish_when_approved as true or false. https://zaisma.com/developers/errors/bad_publish_when_approved
- `bad_match_update_mode` (HTTP 400): match_update_mode isn't next_match or now, or it came without publish_when_approved. Fix: Give match_update_mode as next_match or now, and with an upload only beside publish_when_approved true. https://zaisma.com/developers/errors/bad_match_update_mode
- `version_limit` (HTTP 429): The game has had 100 versions in the last day. Fix: Wait retry_after_sec seconds for the oldest version to pass a day, and test locally with npx @zaisma/cli play-locally in between. https://zaisma.com/developers/errors/version_limit
- `version_in_use` (HTTP 409): The version can't be deleted: it's live, set to publish, or a tester link picked it. Fix: Publish another version, cancel the scheduled publish or change the tester link first, then delete it. https://zaisma.com/developers/errors/version_in_use
- `kept_for_review` (HTTP 403): The version or game is kept for a person at Zaisma, so it can't be deleted. Fix: Wait for the person at Zaisma to finish, as get_version or get_game says. https://zaisma.com/developers/errors/kept_for_review
- `bad_confirm_slug` (HTTP 400): confirm_slug isn't the game's link name. Fix: Give confirm_slug as the game's own slug, exactly. https://zaisma.com/developers/errors/bad_confirm_slug
- `not_waiting_to_erase` (HTTP 409): The game isn't deleted and waiting to be erased, so there's nothing to bring back or erase now. Fix: Call get_game to see the game's state: only a deleted game waiting its week can be brought back or erased now. https://zaisma.com/developers/errors/not_waiting_to_erase
- `already_erasing` (HTTP 409): The game's week is over and its erasing has started, so it can't be brought back. Fix: Make the game again with create_game and upload a version from your own copy. https://zaisma.com/developers/errors/already_erasing
- `played_by_others` (HTTP 409): Other people played this game, so it waits out its week before it's erased; only a game nobody but its developer played can be erased at once. Fix: Let the game wait out its week, or ask the developer to confirm erasing it now on zaisma.com. https://zaisma.com/developers/errors/played_by_others
- `no_game_deletion_request` (HTTP 404): This game has no deletion request with that ID. Fix: Use the game_deletion_request_id from the confirmation_needed answer, or call delete_game again. https://zaisma.com/developers/errors/no_game_deletion_request
- `bad_monthly_storage_budget_cents` (HTTP 400): monthly_storage_budget_cents isn't null or a whole number from 100 to 1,000,000. Fix: Give monthly_storage_budget_cents as null or a whole number from 100 to 1,000,000. https://zaisma.com/developers/errors/bad_monthly_storage_budget_cents
- `no_content_length` (HTTP 411): A file was sent without a Content-Length header. Fix: Send the file with a Content-Length header, as npx @zaisma/cli upload does. https://zaisma.com/developers/errors/no_content_length
- `file_needs_parts` (HTTP 413): A file over 95 MB was sent in one go. Fix: Send files over 95 MB in parts, as the upload answer's part size says, or use npx @zaisma/cli upload. https://zaisma.com/developers/errors/file_needs_parts
- `no_body` (HTTP 400): A file was sent without a body. Fix: Send the file's bytes as the request's body. https://zaisma.com/developers/errors/no_body
- `hash_mismatch` (HTTP 400): A file doesn't match the SHA-256 it was sent as. Fix: Hash the exact bytes you send with SHA-256 and send the file again. https://zaisma.com/developers/errors/hash_mismatch
- `forbidden_file` (HTTP 400): A file is a program or an archive, whatever its name says. Fix: Leave programs and archives out of the game, or unpack the archive into the folder. https://zaisma.com/developers/errors/forbidden_file
- `bad_size_bytes` (HTTP 400): size_bytes isn't a whole number above 0. Fix: Give size_bytes as the file's size in bytes, a whole number above 0. https://zaisma.com/developers/errors/bad_size_bytes
- `bad_part_number` (HTTP 400): A part's number isn't from 1 to 10,000. Fix: Number parts from 1 to 10,000, in order. https://zaisma.com/developers/errors/bad_part_number
- `no_upload_id` (HTTP 400): A part was sent without its upload_id. Fix: Send the upload_id the start of the upload answered with each part. https://zaisma.com/developers/errors/no_upload_id
- `bad_part_size` (HTTP 400): A part is empty, over 50 MB or has no Content-Length header. Fix: Send each part with a Content-Length header, from 1 byte to 50 MB. https://zaisma.com/developers/errors/bad_part_size
- `upload_closed` (HTTP 400): The upload_id isn't an open upload any more. Fix: Start the file's upload again for a new upload_id. https://zaisma.com/developers/errors/upload_closed
- `bad_parts` (HTTP 400): The finishing call isn't { upload_id, parts: [{ part_number, etag }] }. Fix: Finish with { upload_id, parts: [{ part_number, etag }] }, each part's etag as its upload answered. https://zaisma.com/developers/errors/bad_parts
- `parts_incomplete` (HTTP 400): The parts sent don't make a whole file. Fix: Send the missing parts, then finish the file again. https://zaisma.com/developers/errors/parts_incomplete
## Versions and publishing
- `no_version` (HTTP 404): The game has no version with that ID. Fix: Call get_game for the game's version IDs, then call again with one of them. https://zaisma.com/developers/errors/no_version
- `bad_time` (HTTP 400): A time isn't an ISO time in the range it takes: scheduled_publish_at from a few minutes to 90 days ahead, a tester link's ends_at from now to a year ahead, a database restore's restore_to_at within the last 30 days and not before the game was made, a room message's send_at from 10 seconds to 90 days ahead, and a What's on entry's starts_at from an hour ago to 90 days ahead and its ends_at after now and starts_at and at most 60 days after it. Fix: Give an ISO time in UTC within the range the field takes, like "2026-11-01T17:00:00Z". https://zaisma.com/developers/errors/bad_time
- `still_scanning` (HTTP 409): The version is still being scanned. Fix: Wait retry_after_sec seconds, then call get_version until the scan has finished. https://zaisma.com/developers/errors/still_scanning
- `not_approved` (HTTP 409): The version didn't pass review, so it can't be published. Fix: Read the version's review_reason and findings with get_version, fix what they say and upload a new version. https://zaisma.com/developers/errors/not_approved
## Tester links
- `bad_name` (HTTP 400): A tester link's or sign-in app's name isn't 1 to 60 characters, or a sign-in app's says Zaisma. Fix: Give a name of 1 to 60 characters, and for a sign-in app one without the word Zaisma. https://zaisma.com/developers/errors/bad_name
- `too_many_tester_links` (HTTP 403): The game has 50 tester links on already. Fix: Remove a tester link you don't need with remove_tester_link first. https://zaisma.com/developers/errors/too_many_tester_links
- `no_tester_link` (HTTP 404): The game has no tester link on with that ID. Fix: Call get_game for the game's tester link IDs, then call again with one of them. https://zaisma.com/developers/errors/no_tester_link
- `bad_version_choice` (HTTP 400): version_choice isn't live, newest_passed or picked, or picked_version_id doesn't go with it. Fix: Give version_choice as live, newest_passed or picked, and picked_version_id only with picked. https://zaisma.com/developers/errors/bad_version_choice
## Game invites
- `username_not_found` (HTTP 404): No account has that username. Fix: Check the spelling of the username, which is 3 to 20 letters, numbers and underscores, with or without the @. https://zaisma.com/developers/errors/username_not_found
- `game_not_private` (HTTP 409): Only a private or draft game takes invites: a listed or unlisted one opens to everyone already. Fix: Make the game private with update_game (visibility private) first, or share its page_url. https://zaisma.com/developers/errors/game_not_private
- `too_many_game_invites` (HTTP 403): The game has 200 invited accounts already. Fix: Remove an invite you don't need with remove_game_invite first, or make tester links for groups (add_tester_link). https://zaisma.com/developers/errors/too_many_game_invites
- `no_game_invite` (HTTP 404): The game has no invite with that ID. Fix: Call get_game for the game's game_invites with their IDs, then call again with one of them. https://zaisma.com/developers/errors/no_game_invite
- `cannot_invite_self` (HTTP 400): The game's own developer can't be invited: they open it already. Fix: Invite another player's username. https://zaisma.com/developers/errors/cannot_invite_self
## Sign in with Zaisma
- `bad_redirect_urls` (HTTP 400): redirect_urls isn't a list of 1 to 10 https URLs (http only for localhost) without #fragments. Fix: Give redirect_urls as 1 to 10 https addresses without #fragments, or http only for localhost. https://zaisma.com/developers/errors/bad_redirect_urls
- `bad_replace_client_secret` (HTTP 400): replace_client_secret isn't true or false, or the app is public and has no client secret. Fix: Give replace_client_secret as true or false, and only for an app that has a client secret. https://zaisma.com/developers/errors/bad_replace_client_secret
- `too_many_sign_in_apps` (HTTP 403): The account has 20 sign-in apps already. Fix: Delete a sign-in app you don't need with delete_sign_in_app first. https://zaisma.com/developers/errors/too_many_sign_in_apps
- `no_sign_in_app` (HTTP 404): You have no sign-in app with that ID. Fix: Call list_sign_in_apps for your apps' IDs, then call again with one of them. https://zaisma.com/developers/errors/no_sign_in_app
## Webhooks
- `bad_destination_kind` (HTTP 400): destination_kind isn't endpoint_url or game_server. Fix: Give destination_kind as endpoint_url or game_server. https://zaisma.com/developers/errors/bad_destination_kind
- `bad_endpoint_url` (HTTP 400): endpoint_url isn't an https URL on a name (no IP address, user name or #fragment), or it's on Zaisma's own domains, or it's given for a webhook to a game server, which has none. Fix: Give endpoint_url as an https address on a name of your own, without a user name or #fragment, and none for a webhook to a game server. https://zaisma.com/developers/errors/bad_endpoint_url
- `bad_event_kinds` (HTTP 400): event_kinds isn't a list of 1 or more of the webhook event kinds. Fix: Give event_kinds as a list of 1 or more of the event kinds create_webhook's input schema lists. https://zaisma.com/developers/errors/bad_event_kinds
- `bad_game_slugs` (HTTP 400): game_slugs isn't null or a list of 1 to 50 of your games' slugs, or, for a webhook to a game server, a list of the one game whose server it is. Fix: Give game_slugs as null for every game, or 1 to 50 of your games' slugs, and for a webhook to a game server the one game whose server it is. https://zaisma.com/developers/errors/bad_game_slugs
- `bad_replace_signing_secret` (HTTP 400): replace_signing_secret isn't true or false. Fix: Give replace_signing_secret as true or false. https://zaisma.com/developers/errors/bad_replace_signing_secret
- `too_many_webhooks` (HTTP 403): The account has 10 webhooks already. Fix: Delete a webhook you don't need with delete_webhook first. https://zaisma.com/developers/errors/too_many_webhooks
- `no_webhook` (HTTP 404): You have no webhook with that ID. Fix: Call list_webhooks for your webhooks' IDs, then call again with one of them. https://zaisma.com/developers/errors/no_webhook
## The game database
- `bad_sql` (HTTP 400): The SQL isn't one statement SQLite takes, or statements isn't a list of { sql, values }. Fix: Send one statement SQLite takes, with ? for each value, or statements as a list of { sql, values }. https://zaisma.com/developers/errors/bad_sql
- `bad_values` (HTTP 400): values isn't a list of text, numbers, null and { blob_base64 } for the SQL's ?s. Fix: Give values as a list of text, numbers, null and { blob_base64 }, one for each ? in the SQL. https://zaisma.com/developers/errors/bad_values
- `bad_player_id` (HTTP 400): player_id isn't a player ID (player_…). Fix: Give player_id as a player ID like player_…, from a player pass or a purchase. https://zaisma.com/developers/errors/bad_player_id
- `too_many_rows` (HTTP 400): A statement answered more than 10,000 rows. Fix: Add LIMIT and page through the rows, 10,000 at a time at most. https://zaisma.com/developers/errors/too_many_rows
- `integer_too_large` (HTTP 400): A statement answered a whole number past 2^53, which JavaScript can't hold exactly. Fix: Select the number as text with CAST(column AS TEXT). https://zaisma.com/developers/errors/integer_too_large
- `answer_too_big` (HTTP 400): The rows answered come to more than 8 MB. Fix: Select fewer columns or rows at once, with LIMIT and paging. https://zaisma.com/developers/errors/answer_too_big
- `database_full` (HTTP 403): The statement would grow the game's storage (its database and kept rooms) past the 10 GB a game can keep. Fix: Delete rows the game doesn't need, or delete kept rooms, to stay under 10 GB. https://zaisma.com/developers/errors/database_full
- `database_unavailable` (HTTP 503): The game's database didn't answer. Fix: Call again in a minute. https://zaisma.com/developers/errors/database_unavailable
- `database_restore_unavailable` (HTTP 501): This Zaisma's game databases can't go back in time: its storage keeps no history, like a local preview. Fix: Restore databases on zaisma.com, not on a local preview. https://zaisma.com/developers/errors/database_restore_unavailable
- `no_database_restore` (HTTP 404): The game has no database restore with that ID in the last 30 days. Fix: Call get_database for the restores of the last 30 days, then call again with one of their IDs. https://zaisma.com/developers/errors/no_database_restore
- `bad_secret_name` (HTTP 400): A secret's name isn't capitals, digits and underscores starting with a capital, up to 64 characters. Fix: Give the secret's name as capitals, digits and underscores starting with a capital, like DISCORD_TOKEN, up to 64 characters. https://zaisma.com/developers/errors/bad_secret_name
- `bad_secret_value` (HTTP 400): secret_value isn't text of up to 8 KB. Fix: Give secret_value as text of up to 8 KB. https://zaisma.com/developers/errors/bad_secret_value
- `no_secret` (HTTP 404): The game has no secret by that name. Fix: Call list_secrets for the game's secret names, then call again with one of them. https://zaisma.com/developers/errors/no_secret
- `too_many_secrets` (HTTP 403): The game has 50 secrets, the most it can have. Fix: Delete a secret the game doesn't need with delete_secret first. https://zaisma.com/developers/errors/too_many_secrets
- `secrets_unavailable` (HTTP 503): The game's secrets didn't answer. Fix: Call again in a minute. https://zaisma.com/developers/errors/secrets_unavailable
- `no_kept_room` (HTTP 404): The game has no kept room with that code. Fix: Call list_kept_rooms for the game's kept rooms' codes, then call again with one of them. https://zaisma.com/developers/errors/no_kept_room
- `no_kept_room_restore` (HTTP 404): The kept room has no restore with that ID in the last 30 days. Fix: Call list_kept_room_restores for the room's restores, then call again with one of their IDs. https://zaisma.com/developers/errors/no_kept_room_restore
- `no_kept_room_restore_batch` (HTTP 404): The game has no restore of every kept room with that ID in the last 30 days. Fix: Use the batch ID restore_every_kept_room answered, from the last 30 days. https://zaisma.com/developers/errors/no_kept_room_restore_batch
- `kept_room_restore_unavailable` (HTTP 501): This Zaisma's rooms can't go back in time: their storage keeps no history, like a local preview. Fix: Restore kept rooms on zaisma.com, not on a local preview. https://zaisma.com/developers/errors/kept_room_restore_unavailable
- `kept_room_restore_batch_running` (HTTP 409): The game's kept rooms are going back to a moment already, and one batch runs at a time. Fix: Wait for the running batch to finish, as get_kept_room_restore_batch says, then call again. https://zaisma.com/developers/errors/kept_room_restore_batch_running
- `kept_room_copies_unavailable` (HTTP 501): This Zaisma can't read its kept rooms' copies, so an erased kept room can't come back. Fix: Bring the world back on zaisma.com, not on a local preview. https://zaisma.com/developers/errors/kept_room_copies_unavailable
- `no_kept_room_copy` (HTTP 404): No copy of the deleted world is left: a copy lasts about 28 days after a world is deleted. Fix: Start the world again in a new room; no copy of it is left. https://zaisma.com/developers/errors/no_kept_room_copy
- `room_code_in_use` (HTTP 409): Another room of the game has that code now, so the deleted world can't come back under it. Fix: Wait until the room with that code ends, or end it with end_room, then call again. https://zaisma.com/developers/errors/room_code_in_use
- `game_storage_full` (HTTP 403): The deleted world doesn't fit in the 10 GB a game can keep. Fix: Delete rows or kept rooms the game doesn't need to make room under 10 GB, then call again. https://zaisma.com/developers/errors/game_storage_full
- `kept_room_not_waiting` (HTTP 409): The kept room isn't deleted and waiting to be erased, so there's nothing to bring back or erase now. Fix: Call list_kept_rooms to see the room's state: only a deleted room waiting its week can be brought back or erased now. https://zaisma.com/developers/errors/kept_room_not_waiting
- `kept_room_erasing` (HTTP 409): The kept room's week is over and its erasing has started: in a minute it comes back only from its last copy. Fix: Restore the world from its last copy with bring_back_kept_room in a minute. https://zaisma.com/developers/errors/kept_room_erasing
## Reaching live rooms
- `no_room` (HTTP 404): The game has no live room with that code on Zaisma. Fix: Call list_rooms for the game's live rooms' codes, then call again with one of them. https://zaisma.com/developers/errors/no_room
- `no_player_in_room` (HTTP 404): That player isn't in the room now. Fix: Call get_room for the players in the room now, then call again with one of them. https://zaisma.com/developers/errors/no_player_in_room
- `bad_room_message` (HTTP 400): message isn't plain JSON of up to 16 KB. Fix: Give message as plain JSON of up to 16 KB. https://zaisma.com/developers/errors/bad_room_message
- `bad_labels` (HTTP 400): labels isn't a list of up to 4 labels, each { label_name, label_value } of text. Fix: Give labels as up to 4 { label_name, label_value }, each of text. https://zaisma.com/developers/errors/bad_labels
- `bad_kick_message` (HTTP 400): A kick's message isn't text of up to 200 characters. Fix: Give the kick's message as text of up to 200 characters. https://zaisma.com/developers/errors/bad_kick_message
- `bad_end_message` (HTTP 400): An end's message isn't text of up to 200 characters. Fix: Give the end's message as text of up to 200 characters. https://zaisma.com/developers/errors/bad_end_message
- `room_busy` (HTTP 429): The room took 100 room messages in the last second. Fix: Wait retry_after_sec seconds, and send the room fewer messages at once. https://zaisma.com/developers/errors/room_busy
- `every_room_send_limit` (HTTP 429): The game sent to every room 10 times in the last minute, from its game server, the API and the MCP together. Fix: Wait retry_after_sec seconds, and send to every room less often. https://zaisma.com/developers/errors/every_room_send_limit
- `too_many_scheduled_room_messages` (HTTP 409): The game has 100 scheduled room messages waiting, the most it can have. Fix: Cancel a scheduled message with cancel_room_message, or wait for some to be sent. https://zaisma.com/developers/errors/too_many_scheduled_room_messages
- `no_scheduled_room_message` (HTTP 404): The game has no scheduled room message with that ID waiting. Fix: Call list_room_messages for the waiting messages' IDs, then call again with one of them. https://zaisma.com/developers/errors/no_scheduled_room_message
- `dump_too_big` (HTTP 413): dump_sql is over 5 MB: import a dump in parts, each ending on a whole statement. Fix: Import the dump in parts of up to 5 MB, each ending on a whole statement, as npx @zaisma/cli database import does. https://zaisma.com/developers/errors/dump_too_big
## Hosting and credit
- `hosting_paused` (HTTP 429): The game's hosting is paused this month: its free allowance, its budget or its developer's credit is used, or Zaisma's free hosting ran out and it has no budget with credit, or it has no real players and games with none used their share. It starts again when the month resets, the budget is raised or credit is added. Fix: Call get_credit to see why, then top up with top_up_credit, raise the game's budget with update_game, or wait for the next month. https://zaisma.com/developers/errors/hosting_paused
- `confirmation_needed` (HTTP 403): This needs the developer's passkey on zaisma.com (turning spending on or up, connecting a Stripe account, deleting a game other people played, or erasing a waiting game or kept room's world at once): confirm_url is where they do it. Fix: Show the developer confirm_url, where they confirm with their passkey, then check their answer with the request ID the error gives. https://zaisma.com/developers/errors/confirmation_needed
- `bad_monthly_budget_cents` (HTTP 400): monthly_budget_cents isn't a whole number of cents of at least 100 ($1), or null for no paid hosting. Fix: Give monthly_budget_cents as a whole number of cents of at least 100, or null for no paid hosting. https://zaisma.com/developers/errors/bad_monthly_budget_cents
- `bad_top_up_amount` (HTTP 400): amount_cents isn't a whole number of cents from 1,000 ($10) to 100,000 ($1,000). Fix: Give amount_cents as a whole number of cents from 1,000 to 100,000. https://zaisma.com/developers/errors/bad_top_up_amount
- `account_not_protected` (HTTP 403): The account has no passkey and no email yet, and a top-up keeps a card, so it needs one of them first: add a passkey or an email on zaisma.com/account. Fix: Ask the developer to add a passkey or an email on zaisma.com/account, then top up again. https://zaisma.com/developers/errors/account_not_protected
- `money_paused` (HTTP 423): Top-ups and credit refunds on this account passed USD 2,000.00 in a day, so both are paused until a person at Zaisma looks. Credit already there keeps working. The developer gets an email when they're on again. Fix: Wait for the email saying top-ups are on again; credit already there keeps working. https://zaisma.com/developers/errors/money_paused
- `new_payer_limit` (HTTP 403): A new account, or an account with a newly saved card, pays up to USD 100.00 in all, buys and credit together, in its first 7 days; this payment would go past it. The message says the day it lifts. Fix: Wait until the day the message names, or pay less now. https://zaisma.com/developers/errors/new_payer_limit
- `no_top_up` (HTTP 404): You have no top-up with that ID. Fix: Call get_credit for the account's top-ups, then call again with one of their IDs. https://zaisma.com/developers/errors/no_top_up
- `no_spending_request` (HTTP 404): You have no spending request with that ID. Fix: Use the spending_request_id from the confirmation_needed answer. https://zaisma.com/developers/errors/no_spending_request
- `top_up_not_refundable` (HTTP 409): The top-up has nothing left to refund: it's spent, refunded, or over 30 days old. Fix: Call get_credit to see which top-ups still have credit to refund within their 30 days. https://zaisma.com/developers/errors/top_up_not_refundable
- `bad_refill_level_cents` (HTTP 400): refill_level_cents isn't a whole number of cents from 1,000 ($10) to 1,000,000 ($10,000). Fix: Give refill_level_cents as a whole number of cents from 1,000 to 1,000,000. https://zaisma.com/developers/errors/bad_refill_level_cents
- `already_credit_plan` (HTTP 409): The developer already has a monthly credit plan, so there's nothing to start: change its level or stop it. Fix: Change the plan's level with change_credit_plan, or stop it with stop_credit_plan. https://zaisma.com/developers/errors/already_credit_plan
- `no_credit_plan` (HTTP 409): The developer has no monthly credit plan to change or stop. Fix: Start one with start_credit_plan first. https://zaisma.com/developers/errors/no_credit_plan
- `already_pro` (HTTP 409): The developer already has a Zaisma Pro subscription (running, cancelled until the month ends, or a renewal Stripe is retrying), so there's nothing to start. Fix: Call get_pro to see the subscription, and resume_pro if it's cancelled. https://zaisma.com/developers/errors/already_pro
- `pro_not_refundable` (HTTP 409): Zaisma Pro's payment can't be refunded: only the first payment, within 14 days of it, and only while it's the only one. Fix: Cancel Zaisma Pro with cancel_pro so it ends with the month instead. https://zaisma.com/developers/errors/pro_not_refundable
- `not_pro` (HTTP 409): There's nothing to cancel or resume: the developer has no Zaisma Pro, or it's already cancelled (or isn't cancelled). Fix: Call get_pro to see the subscription's state, then start_pro, cancel_pro or resume_pro as it fits. https://zaisma.com/developers/errors/not_pro
- `stripe_unavailable` (HTTP 503): Stripe didn't answer, or this Zaisma has no Stripe account set up. Fix: Call again in a few minutes. https://zaisma.com/developers/errors/stripe_unavailable
## A game server's logs
- `bad_room_code` (HTTP 400): room_code isn't a room's code: six characters like K7Q2MX. Fix: Give room_code as a room's six-character code, like K7Q2MX. https://zaisma.com/developers/errors/bad_room_code
- `bad_minimum_level` (HTTP 400): minimum_level isn't debug, info, warn or error. Fix: Give minimum_level as debug, info, warn or error. https://zaisma.com/developers/errors/bad_minimum_level
- `bad_source_kind` (HTTP 400): source_kind isn't room, request, schedule or webhook. Fix: Give source_kind as room, request, schedule or webhook. https://zaisma.com/developers/errors/bad_source_kind
- `bad_search_text` (HTTP 400): search_text is empty or over 200 characters. Fix: Give search_text of 1 to 200 characters. https://zaisma.com/developers/errors/bad_search_text
- `bad_maximum_line_count` (HTTP 400): maximum_line_count isn't a whole number from 1 to 500. Fix: Give maximum_line_count as a whole number from 1 to 500. https://zaisma.com/developers/errors/bad_maximum_line_count
- `two_log_cursors` (HTTP 400): get_logs got both cursor and new_lines_cursor. Fix: Send cursor to page back, or new_lines_cursor to follow, not both. https://zaisma.com/developers/errors/two_log_cursors
## Items and purchases
- `no_item` (HTTP 404): The game has no item by that name. Fix: Call list_items for the game's item names, then call again with one of them. https://zaisma.com/developers/errors/no_item
- `too_many_items` (HTTP 400): The game has 1,000 items, the most it can have. Fix: Remove items the game no longer uses with remove_item first. https://zaisma.com/developers/errors/too_many_items
- `bad_item` (HTTP 400): An item's name, title, description, kind, category, price or local prices isn't one set_item takes; field says which. Fix: Fix the item's field named in field, as set_item's input schema says. https://zaisma.com/developers/errors/bad_item
- `unsupported_currency` (HTTP 400): Zaisma doesn't price in that currency. Fix: Price the item in one of the currencies set_item's input schema lists. https://zaisma.com/developers/errors/unsupported_currency
- `price_too_low` (HTTP 400): The price is under the least Stripe charges in its currency. Fix: Raise the price to at least the least Stripe charges in that currency. https://zaisma.com/developers/errors/price_too_low
- `refund_policy_needed` (HTTP 409): A game that sells anything states its refund policy first. Fix: Set the game's refund policy with set_purchase_settings first. https://zaisma.com/developers/errors/refund_policy_needed
- `bad_refund_policy` (HTTP 400): refund_policy isn't no_refunds, unused_within_14_days, within_14_days, own_words or null. Fix: Give refund_policy as no_refunds, unused_within_14_days, within_14_days, own_words or null. https://zaisma.com/developers/errors/bad_refund_policy
- `bad_refund_policy_text` (HTTP 400): refund_policy_text isn't up to 600 characters of plain words, or doesn't go with refund_policy own_words. Fix: Give refund_policy_text as up to 600 characters of plain words, only with refund_policy own_words. https://zaisma.com/developers/errors/bad_refund_policy_text
- `bad_own_payment_categories` (HTTP 400): own_payment_categories isn't a list of cosmetic, gameplay, content and currency. Fix: Give own_payment_categories as a list from cosmetic, gameplay, content and currency. https://zaisma.com/developers/errors/bad_own_payment_categories
- `item_has_owners` (HTTP 409): Players bought or were granted the item, so it can't be removed; take its price off to stop selling it. Fix: Take the item's price off with set_item to stop selling it, and keep it for those who own it. https://zaisma.com/developers/errors/item_has_owners
- `bad_item_count` (HTTP 400): item_count isn't a whole number from 1 to 1,000, isn't 1 for a permanent item, or makes a buy's total more than 99,999,999 minor units. Fix: Give item_count as a whole number from 1 to 1,000, and 1 for a permanent item. https://zaisma.com/developers/errors/bad_item_count
- `bad_game_account_id` (HTTP 400): game_account_id isn't text of up to 200 characters, or null. Fix: Give game_account_id as text of up to 200 characters, or null. https://zaisma.com/developers/errors/bad_game_account_id
- `bad_purchase_source` (HTTP 400): purchase_source isn't sale or grant. Fix: Give purchase_source as sale or grant. https://zaisma.com/developers/errors/bad_purchase_source
- `bad_purchase_status` (HTTP 400): purchase_status isn't pending, completed, failed, refunded or charged_back. Fix: Give purchase_status as pending, completed, failed, refunded or charged_back. https://zaisma.com/developers/errors/bad_purchase_status
- `no_purchase` (HTTP 404): The game has no purchase with that ID. Fix: Call list_purchases for the game's purchase IDs, then call again with one of them. https://zaisma.com/developers/errors/no_purchase
- `already_refunded` (HTTP 409): The purchase was refunded or charged back already. Fix: Call get_purchase to see the refund that's there; nothing more is needed. https://zaisma.com/developers/errors/already_refunded
- `stripe_not_connected` (HTTP 409): Selling with the buy sheet, and refunding a sale, go through the developer's own Stripe account, which isn't connected: connect_stripe_account. Fix: Connect the developer's Stripe account with connect_stripe_account first. https://zaisma.com/developers/errors/stripe_not_connected
- `stripe_cannot_take_payments` (HTTP 409): The developer's Stripe account is connected, but Stripe hasn't turned on payments for it yet: finish setting it up on Stripe's dashboard. Fix: Finish setting the account up on Stripe's dashboard, then check with get_stripe_account. https://zaisma.com/developers/errors/stripe_cannot_take_payments
- `stripe_account_banned` (HTTP 403): The Stripe account was banned from Zaisma with the account that connected it, so it can't be connected again. Fix: Connect another Stripe account, of an account Zaisma hasn't banned. https://zaisma.com/developers/errors/stripe_account_banned
- `email_banned` (HTTP 403): The email was banned from Zaisma with the account it was on, so it can't be added to an account. Fix: Use another email. https://zaisma.com/developers/errors/email_banned
- `bad_is_stripe_tax_used` (HTTP 400): is_stripe_tax_used isn't true or false. Fix: Give is_stripe_tax_used as true or false. https://zaisma.com/developers/errors/bad_is_stripe_tax_used
- `bad_amount_minor_units` (HTTP 400): amount_minor_units isn't a whole number from 1 to what's left of the sale to refund. Fix: Give amount_minor_units as a whole number from 1 to what's left of the sale to refund, as get_purchase shows. https://zaisma.com/developers/errors/bad_amount_minor_units
- `purchase_not_paid` (HTTP 409): The sale wasn't paid (pending or failed), so there's nothing to refund. Fix: Leave the sale as it is: nothing was paid, so nothing is owed. https://zaisma.com/developers/errors/purchase_not_paid
- `not_for_sale` (HTTP 409): The item has no price, so players can't buy it; it's only granted. Fix: Give the item a price with set_item to sell it, or grant it with grant_item. https://zaisma.com/developers/errors/not_for_sale
- `receipts_unavailable` (HTTP 503): Zaisma couldn't sign the purchase's receipt at that moment. A grant answered with it wasn't made, so trying again grants it once. Fix: Call again in a minute: the grant wasn't made, so it's made once. https://zaisma.com/developers/errors/receipts_unavailable
- `bad_purchase_delivery` (HTTP 400): purchase_delivery isn't game, game_server or own_server. Fix: Give purchase_delivery as game, game_server or own_server. https://zaisma.com/developers/errors/bad_purchase_delivery
- `no_game_server` (HTTP 409): purchase_delivery game_server needs a game server, on Zaisma or the developer's own, and the game has none. Fix: Give the game a game server, or set purchase_delivery to game. https://zaisma.com/developers/errors/no_game_server
- `already_handled` (HTTP 409): The purchase was handed over already, or its refund was told already. Fix: Leave it: the purchase was handed over already. https://zaisma.com/developers/errors/already_handled
- `handled_by_server` (HTTP 409): The game's purchases go to its game server or the developer's own server (purchase_delivery), so the game can't mark them handled. Fix: Mark the purchase handled from the game server or your own server, which purchase_delivery names. https://zaisma.com/developers/errors/handled_by_server
- `bad_full_game_item` (HTTP 400): full_game_item_name doesn't name one of the game's items that's permanent and content, or the game is another game's demo. Fix: Name one of the game's items that's permanent and content, set with set_item. https://zaisma.com/developers/errors/bad_full_game_item
- `full_game_item_in_use` (HTTP 409): The item is the game's full game (full_game_item_name), so it can't be removed or stop being permanent and content. Fix: Set full_game_item_name to another item, or null, with update_game first. https://zaisma.com/developers/errors/full_game_item_in_use
- `bad_demo_game` (HTTP 400): demo_game_slug isn't another of the developer's games that's free to play, or the game itself is free to play. Fix: Give demo_game_slug as another of your games that's free to play, from a game that sells itself. https://zaisma.com/developers/errors/bad_demo_game
- `account_requirement_locked` (HTTP 400): A game that sells itself (full_game_item_name) needs account_requirement whole_game, since only accounts own it. Fix: Keep account_requirement whole_game, or stop selling the game with full_game_item_name null first. https://zaisma.com/developers/errors/account_requirement_locked
- `full_game_not_owned` (HTTP 403): The game sells itself, and the player's account doesn't own it: buy it on its game page. Fix: Let the player buy the game on its game page, or grant it with grant_item. https://zaisma.com/developers/errors/full_game_not_owned
## Cloud saves
- `no_save` (HTTP 404): The player has no save in the game. Fix: Check the player ID, and that the player has played the game signed in with cloud saves on. https://zaisma.com/developers/errors/no_save
- `no_save_copy` (HTTP 404): The player's save has no earlier version with that ID. Fix: Call list_save_copies for the save's earlier versions, then call again with one of their IDs. https://zaisma.com/developers/errors/no_save_copy
- `bad_keys` (HTTP 400): keys isn't a list of 1 to 100 localStorage keys of up to 1,000 characters. Fix: Give keys as a list of 1 to 100 localStorage keys, each up to 1,000 characters. https://zaisma.com/developers/errors/bad_keys
- `bad_local_storage_items` (HTTP 400): local_storage_items isn't an object of localStorage keys and their text (null removes a key in a change). Fix: Give local_storage_items as an object of keys and their text, with null to remove a key in a change. https://zaisma.com/developers/errors/bad_local_storage_items
- `bad_indexeddb_databases` (HTTP 400): indexeddb_databases isn't a list of databases, each { name, version, stores } as get_save answers them. Fix: Give indexeddb_databases as get_save answered them, each { name, version, stores }. https://zaisma.com/developers/errors/bad_indexeddb_databases
- `save_too_big` (HTTP 413): The save would be over 5 MB. Fix: Keep the save under 5 MB, saving less or smaller values. https://zaisma.com/developers/errors/save_too_big
- `cloud_saves_off` (HTTP 409): The game has cloud saves off, so it doesn't read saves from players' accounts. Fix: Turn cloud saves on with update_game, cloud_saves_enabled true. https://zaisma.com/developers/errors/cloud_saves_off
- `cloud_saves_not_here` (HTTP 409): Cloud saves don't work here: this is a tester link, or this Zaisma has no accounts. The game page answers it to `Zaisma.saves` and `Zaisma.player.offerAccount()`; no API or MCP call returns it. Fix: Test cloud saves on the game's zaisma.com page, signed in, not through a tester link. https://zaisma.com/developers/errors/cloud_saves_not_here
- `save_busy` (HTTP 409): The player's game kept saving at the same moment, so the change didn't go through. Fix: Call again in a moment. https://zaisma.com/developers/errors/save_busy
## The inbox
- `no_inbox_notice` (HTTP 404): There's no notice with that ID in the account's inbox: deleted, past its 90 days, or never its own. Fix: List the inbox with list_inbox and use an inbox_notice_id it answers. https://zaisma.com/developers/errors/no_inbox_notice
- `bad_inbox_section` (HTTP 400): inbox_section isn't for_you or your_games. Fix: Give inbox_section as for_you or your_games. https://zaisma.com/developers/errors/bad_inbox_section
- `bad_is_read` (HTTP 400): is_read isn't true or false. Fix: Give is_read as true or false. https://zaisma.com/developers/errors/bad_is_read
- `bad_is_archived` (HTTP 400): is_archived isn't true or false. Fix: Give is_archived as true or false. https://zaisma.com/developers/errors/bad_is_archived
- `bad_turned_off_notice_kinds` (HTTP 400): turned_off_notice_kinds isn't a list of the inbox's kinds, or names account_security or legal, which always come. Fix: Give turned_off_notice_kinds as the whole list of kinds to turn off, from those list_inbox's notice_kinds says can_turn_off. https://zaisma.com/developers/errors/bad_turned_off_notice_kinds
- `too_many_notices` (HTTP 429): The game sent 3 update and event notices in the last 7 days, the most a week takes. Fix: Send it once retry_after_sec has passed, or fold it into the next notice. https://zaisma.com/developers/errors/too_many_notices
- `game_not_playable` (HTTP 409): The game isn't live and listed or unlisted, so nobody follows it to hear about an event. Fix: Publish a version and set visibility listed or unlisted with update_game, then announce the event. https://zaisma.com/developers/errors/game_not_playable
- `bad_starts_at` (HTTP 400): starts_at isn't an ISO time from now to 90 days ahead. Fix: Give starts_at as an ISO time, like 2026-12-05T18:00:00Z, within the next 90 days. https://zaisma.com/developers/errors/bad_starts_at
- `bad_ends_at` (HTTP 400): ends_at isn't an ISO time after starts_at and at most 30 days after it. Fix: Give ends_at as an ISO time after starts_at, at most 30 days later, or null for none. https://zaisma.com/developers/errors/bad_ends_at
- `no_bug_report` (HTTP 404): The game has no bug report with that report_id from the last 90 days. Fix: Take a bug report's id from get_reports. https://zaisma.com/developers/errors/no_bug_report
- `already_replied` (HTTP 409): The game's developer already replied to this bug report or feedback: one reply each. Fix: Put what's new in the next update's patch notes instead. https://zaisma.com/developers/errors/already_replied
- `bad_reply_text` (HTTP 400): reply_text isn't 1 to 1,000 characters of text that shows. Fix: Give reply_text as a short answer to the player, up to 1,000 characters. https://zaisma.com/developers/errors/bad_reply_text
## Player feedback
- `no_feedback` (HTTP 404): The game has no feedback with that feedback_id. Fix: Take a feedback_id from get_feedback. https://zaisma.com/developers/errors/no_feedback
- `no_feedback_picture` (HTTP 404): That feedback has no picture by that name. Fix: Use a picture_url from get_feedback as it is. https://zaisma.com/developers/errors/no_feedback_picture
- `feedback_from_guest` (HTTP 409): A guest sent that feedback, or it's older than 90 days, when who sent it is cleared: there's no inbox to answer. Fix: Answer feedback whose is_from_guest is false, from the last 90 days. https://zaisma.com/developers/errors/feedback_from_guest
## The developer forum
- `no_topic` (HTTP 404): There's no topic with that ID you can see. Fix: Call search_forum for the topic's ID, then call again with it. https://zaisma.com/developers/errors/no_topic
- `no_post` (HTTP 404): There's no post with that ID you can see in the topic. Fix: Call get_topic for the topic's post IDs, then call again with one of them. https://zaisma.com/developers/errors/no_post
- `no_known_issue` (HTTP 404): There's no known issue with that ID. Fix: Call search_forum with tab known for the known issues' IDs. https://zaisma.com/developers/errors/no_known_issue
- `no_media` (HTTP 404): There's no image there you can see. Fix: Use an image address from a post you can see. https://zaisma.com/developers/errors/no_media
- `bad_tab` (HTTP 400): tab isn't latest, top, unanswered, known, yours, messages or bookmarks. Fix: Give tab as latest, top, unanswered, known, yours, messages or bookmarks. https://zaisma.com/developers/errors/bad_tab
- `bad_section` (HTTP 400): section isn't one of the forum's sections. Fix: Give section as one of the sections search_forum's input schema lists. https://zaisma.com/developers/errors/bad_section
- `contact_details_in_post` (HTTP 400): A public forum post or its title holds an email address or asks to be reached somewhere else ("add me on…", "my Discord is…"): developers can be 13. Fix: Take the contact details out; a private topic (is_public false) reaches Zaisma, and replies in the topic reach the others. https://zaisma.com/developers/errors/contact_details_in_post
- `link_not_allowed_in_post` (HTTP 400): A public forum post or its title links to a site outside the trusted list and the forum's developer sites (GitHub, MDN, npm, Stack Overflow, Zaisma's own, local addresses). Fix: Take the link out, or point to the same thing on one of those sites; ask on the forum for another site to be added. https://zaisma.com/developers/errors/link_not_allowed_in_post
- `bad_category` (HTTP 400): category isn't one of the forum's categories. Fix: Give category as one of the categories post_topic's input schema lists. https://zaisma.com/developers/errors/bad_category
- `no_category` (HTTP 400): A public topic was sent without its category. Fix: Give a public topic a category, as post_topic's input schema lists. https://zaisma.com/developers/errors/no_category
- `bad_tag` (HTTP 400): tag isn't one of the forum's tags. Fix: Give tag as one of the tags search_forum's input schema lists. https://zaisma.com/developers/errors/bad_tag
- `bad_tags` (HTTP 400): tags isn't a list of up to 3 of the forum's tags. Fix: Give tags as up to 3 of the tags post_topic's input schema lists. https://zaisma.com/developers/errors/bad_tags
- `bad_topic_status` (HTTP 400): topic_status isn't one of the statuses. Fix: Give topic_status as one of the statuses the input schema lists. https://zaisma.com/developers/errors/bad_topic_status
- `bad_is_answered` (HTTP 400): is_answered isn't true or false. Fix: Give is_answered as true or false. https://zaisma.com/developers/errors/bad_is_answered
- `bad_maximum_topic_count` (HTTP 400): maximum_topic_count isn't a whole number from 1 to 30. Fix: Give maximum_topic_count as a whole number from 1 to 30. https://zaisma.com/developers/errors/bad_maximum_topic_count
- `bad_detail` (HTTP 400): detail isn't brief. Fix: Give detail as brief, or leave it out. https://zaisma.com/developers/errors/bad_detail
- `bad_post_selection` (HTTP 400): post_selection isn't all, answer, latest or none. Fix: Give post_selection as all, answer, latest or none. https://zaisma.com/developers/errors/bad_post_selection
- `bad_is_public` (HTTP 400): is_public isn't true or false. Fix: Give is_public as true or false. https://zaisma.com/developers/errors/bad_is_public
- `bad_text_markdown` (HTTP 400): text_markdown is empty or over 8,000 characters. Fix: Give text_markdown of 1 to 8,000 characters. https://zaisma.com/developers/errors/bad_text_markdown
- `bad_author_kind` (HTTP 400): author_kind isn't developer or ai. Fix: Give author_kind as developer or ai. https://zaisma.com/developers/errors/bad_author_kind
- `bad_debug_context` (HTTP 400): debug_context isn't an object of its five text fields, up to 8,000 characters in all. Fix: Give debug_context as an object of its five text fields, up to 8,000 characters in all. https://zaisma.com/developers/errors/bad_debug_context
- `bad_images_base64` (HTTP 400): images_base64 isn't a list of base64 images. Fix: Give images_base64 as a list of PNG, WebP or JPEG images in base64. https://zaisma.com/developers/errors/bad_images_base64
- `too_many_images` (HTTP 400): A post carries more than 10 images. Fix: Send at most 10 images with a post. https://zaisma.com/developers/errors/too_many_images
- `bad_reopen` (HTTP 400): reopen isn't true or false. Fix: Give reopen as true or false. https://zaisma.com/developers/errors/bad_reopen
- `bad_answer_post_id` (HTTP 400): answer_post_id isn't a post ID or null. Fix: Give answer_post_id as a post ID from get_topic, or null. https://zaisma.com/developers/errors/bad_answer_post_id
- `bad_reason` (HTTP 400): reason isn't one of the report reasons. Fix: Give reason as one of the reasons report_post's input schema lists. https://zaisma.com/developers/errors/bad_reason
- `post_limit` (HTTP 429): The account has posted 100 times in the last day. Fix: Wait retry_after_sec seconds before posting again. https://zaisma.com/developers/errors/post_limit
- `image_limit` (HTTP 429): The account has uploaded 200 forum images in the last day. Fix: Wait retry_after_sec seconds before sending more images. https://zaisma.com/developers/errors/image_limit
- `not_yours` (HTTP 403): Only the developer who started the topic can do that. Fix: Ask the developer who started the topic, or reply to it with reply_to_topic. https://zaisma.com/developers/errors/not_yours
- `not_a_question` (HTTP 400): Only a question has an answer to mark. Fix: Mark answers only in topics of kind question. https://zaisma.com/developers/errors/not_a_question
- `not_closed` (HTTP 400): The topic isn't closed, so there's nothing to reopen. Fix: Leave it: the topic is open already. https://zaisma.com/developers/errors/not_closed
- `not_released` (HTTP 400): The topic isn't a known issue whose fix is out. Fix: Wait until the known issue's fix is out, as get_topic shows. https://zaisma.com/developers/errors/not_released
- `cant_vote` (HTTP 400): The topic doesn't take your vote: it's yours, private, or a discussion. Fix: Vote only on others' public topics that aren't discussions. https://zaisma.com/developers/errors/cant_vote
- `cant_flag` (HTTP 400): Only public topics others can see can be flagged as misplaced. Fix: Flag only public topics others can see. https://zaisma.com/developers/errors/cant_flag
- `retired_tool` (HTTP 410): The tool is retired; the error names the one that replaces it. Fix: Call the tool the message names instead. https://zaisma.com/developers/errors/retired_tool
- `bad_rating` (HTTP 400): rating isn't like or dislike. Fix: Give rating as like or dislike. https://zaisma.com/developers/errors/bad_rating
- `cant_rate_post` (HTTP 400): Only posts in public topics take likes and dislikes. Fix: Rate only posts in public topics. https://zaisma.com/developers/errors/cant_rate_post
- `cant_rate_own_post` (HTTP 400): Your own posts take no likes or dislikes from you. Fix: Rate only other people's posts. https://zaisma.com/developers/errors/cant_rate_own_post
- `cant_report` (HTTP 400): The post can't be reported: it's yours, or Zaisma's. Fix: Report only others' posts, never your own or Zaisma's. https://zaisma.com/developers/errors/cant_report
## The developer marketplace
- `no_piece` (HTTP 404): There's no piece with that name you can see. Fix: Call search_pieces for the marketplace's pieces, or list_pieces for your own, then call again with one's name. https://zaisma.com/developers/errors/no_piece
- `no_piece_version` (HTTP 404): The piece has no version with that number, or none that passed its checks. Fix: Call get_piece for the piece's versions, then call again with one of their piece_version. https://zaisma.com/developers/errors/no_piece_version
- `no_piece_file` (HTTP 404): That version of the piece has no file at that path. Fix: Call get_piece_version for the version's files, then call again with one of their paths. https://zaisma.com/developers/errors/no_piece_file
- `no_piece_statement` (HTTP 400): A piece was sent without its piece.json. Fix: Send the piece's statement with the path piece.json, as docs/PIECES.md describes it. https://zaisma.com/developers/errors/no_piece_statement
- `bad_piece_statement` (HTTP 400): A piece's piece.json isn't one: field names what's wrong in it. Fix: Fix the field the message names in the piece.json; zaisma pieces check <folder> finds the same problem before publishing. https://zaisma.com/developers/errors/bad_piece_statement
- `piece_statement_newer` (HTTP 400): A piece's piece.json is written in a newer format than Zaisma reads. Fix: Write the piece.json in the format docs/PIECES.md describes, with the statement_version_number it gives. https://zaisma.com/developers/errors/piece_statement_newer
- `piece_files_disagree` (HTTP 400): The files sent aren't the ones the piece.json lists: one is missing, or one isn't listed. Fix: Send piece.json and exactly the files its file_paths and server_file_paths list; zaisma pieces publish <folder> does. https://zaisma.com/developers/errors/piece_files_disagree
- `piece_too_big` (HTTP 413): A piece has more than 5,000 files or over 500 MB in all, or a skill is over 5 MB. Fix: Split it into smaller pieces, like a pack per theme, or pack small files together. https://zaisma.com/developers/errors/piece_too_big
- `piece_name_taken` (HTTP 409): Another developer has that name on the marketplace, or publishes under its scope. Fix: Give the piece a name under a scope of your own in its piece.json, like @your-studio/its-name. https://zaisma.com/developers/errors/piece_name_taken
- `piece_version_exists` (HTTP 409): The piece already has that version: a published version never changes. Fix: Raise piece_version in the piece.json and publish again; delete_piece_version removes a version nobody should get any more. https://zaisma.com/developers/errors/piece_version_exists
- `piece_version_breaks` (HTTP 409): A piece's new version keeps the first number of the one below it (the first two below 1.0.0), saying nothing broke, but takes away or changes something games built on that one use: a setting, a hook, an export, a need's range, or a pack's file. Fix: Publish it under the version the message names, which tells games it breaks; or keep what the earlier version offered and publish again. https://zaisma.com/developers/errors/piece_version_breaks
- `piece_removed` (HTTP 403): Zaisma took the piece down, so it takes no new versions and nobody can fetch it. Fix: Read the piece's review_reason in get_piece, and reach Zaisma with message_zaisma if it's a mistake. https://zaisma.com/developers/errors/piece_removed
- `too_many_piece_versions` (HTTP 429): The piece got as many versions today as it can. Fix: Publish the next version after retry_after_sec seconds. https://zaisma.com/developers/errors/too_many_piece_versions
- `piece_file_not_shown` (HTTP 400): The file isn't text, or is over 256 KB, so it's fetched, not read. Fix: Fetch the piece with zaisma pieces add or zaisma pieces get to read the file on your computer. https://zaisma.com/developers/errors/piece_file_not_shown
- `piece_fetch_off` (HTTP 403): The API key can't fetch other developers' pieces: its developer chose that when making it. Fix: Tell the developer; a key or connected app that asks first or downloads freely is made on zaisma.com/dashboard/settings. https://zaisma.com/developers/errors/piece_fetch_off
- `piece_approval_needed` (HTTP 403): The API key asks the developer before fetching another developer's piece, and they haven't said yes to this one: confirm_url is its listing, where they do. Fix: Show the developer confirm_url, where they read what the piece is and say yes or no, then call again. https://zaisma.com/developers/errors/piece_approval_needed
- `piece_fetch_declined` (HTTP 403): The developer said no to fetching this piece. Fix: Don't fetch the piece another way; the developer changes their answer on its listing (confirm_url). https://zaisma.com/developers/errors/piece_fetch_declined
- `bad_piece_kind` (HTTP 400): kind isn't a kind of piece. Fix: Give kind as foundation, extension, game_system, template, pack, preset, skill or tool, or leave it out for every kind. https://zaisma.com/developers/errors/bad_piece_kind
- `bad_sort` (HTTP 400): sort isn't quality or newest. Fix: Give sort as quality or newest, or leave it out for quality. https://zaisma.com/developers/errors/bad_sort
- `bad_piece_name` (HTTP 400): A piece's or a standard's name isn't a name as npm takes them. Fix: Give the name as its statement states it, like @studio/dash-move. https://zaisma.com/developers/errors/bad_piece_name
- `bad_version_range` (HTTP 400): version_range isn't a version or a semver range. Fix: Give a version like 1.2.0 or a range like ^1.2, or leave it out for the newest. https://zaisma.com/developers/errors/bad_version_range
- `bad_piece_visibility` (HTTP 400): A piece's visibility isn't private, unlisted or listed. Fix: Give visibility as private, unlisted or listed. https://zaisma.com/developers/errors/bad_piece_visibility
- `bad_source_url` (HTTP 400): source_url isn't an https address on a site that hosts source code. Fix: Give source_url as the piece's repository on github.com, gitlab.com, codeberg.org, bitbucket.org or sr.ht, or null for none. https://zaisma.com/developers/errors/bad_source_url
- `bad_confirm_piece_name` (HTTP 400): confirm_piece_name isn't the piece's name. Fix: Give confirm_piece_name as the piece's own name, exactly. https://zaisma.com/developers/errors/bad_confirm_piece_name
- `too_many_piece_pictures` (HTTP 400): The piece's listing has 8 gallery pictures already. Fix: Remove a gallery picture with remove_piece_image before adding another. https://zaisma.com/developers/errors/too_many_piece_pictures
- `no_piece_image` (HTTP 404): The piece's listing has no picture with that id. Fix: Read the listing's pictures with get_piece and give one's id. https://zaisma.com/developers/errors/no_piece_image
- `image_not_checked` (HTTP 503): Image matching didn't answer, so a listing's picture wasn't kept. Fix: Send the picture again in a few minutes. https://zaisma.com/developers/errors/image_not_checked
- `cant_rate_own_piece` (HTTP 400): Your own pieces take no likes or dislikes from you. Fix: Rate only other developers' pieces. https://zaisma.com/developers/errors/cant_rate_own_piece
- `bad_report_reason` (HTTP 400): report_reason isn't one of the reasons the tool takes. Fix: Give report_reason as one of the reasons the tool's input schema lists (report_piece, report_feedback). https://zaisma.com/developers/errors/bad_report_reason
- `bad_report_details` (HTTP 400): details is over 1,000 characters, or isn't text. Fix: Give details as up to 1,000 characters saying what's wrong and where. https://zaisma.com/developers/errors/bad_report_details
references/game-server.md
CodeCopied
<!-- Made by scripts/build-skill.mjs: never edit it by hand. -->
# @zaisma/game-server
Write a game server once; run it in Zaisma's rooms or on your own Node server. Rooms, players, state sync, chat, the game's database and its requests behave the same in both.
To play your multiplayer game on your own computer before you upload it, run `npx @zaisma/game-server@1 play-locally` in the game's folder (or `npx @zaisma/cli play-locally`, which runs it). When it starts, it asks npm whether a newer bench is out and, if one is, says so in one line: run it again to use it, or, where your project or computer installed an older one, the `npm install` that moves it up. Offline, or on the latest, it says nothing and never waits. It serves the game, runs its game server, and opens a test bench: each player on Zaisma's own game page, guests until they sign in with a name, and a dev bar whose Add a player opens another tab as a new player, with passes signed by a key of its own, so two tabs play together with no account, key or internet. Flags: `[folder]`, `--port 4800`, `--game <slug>`, `--on-network`, `--no-open`, `--json`; Zaisma's README has the whole of it under "Play it on your own computer".
```ts
// server.ts
import { defineGameServer } from "@zaisma/game-server";
export default defineGameServer({
ticksPerSec: 20,
setup: () => ({ scores: {} }),
onJoin: (state, who, room) => ({ ...state, scores: { ...state.scores, [who.id]: 0 } }),
});
```
On your own server (Node 22.18 or later):
```
npx @zaisma/game-server@1 ./server.ts --game <your-game-slug> --port 8080
```
or from code:
```ts
import { startServer } from "@zaisma/game-server/node";
import gameServer from "./server.ts";
const running = startServer({ gameServer, gameSlug: "your-game-slug", port: 8080 });
// Later: await running.close(); every room saves first.
```
For the fast lane (WebTransport, where `latest_only` sends go as datagrams), install its two optional packages beside the runner and give it all three of `--webtransport-port`, `--certificate-path` and `--certificate-key-path` (`startServer({ webtransportPort, certificatePath, certificateKeyPath })`):
```
npm install @fails-components/webtransport@1.6.11 @fails-components/webtransport-transport-http3-quiche@1.6.11
npx @zaisma/game-server@1 ./server.ts --game <your-game-slug> --port 8080 --webtransport-port 443 --certificate-path fullchain.pem --certificate-key-path privkey.pem
```
Games join it with `Zaisma.joinRoom({ serverUrl, transport: "webtransport" })`, and fall back to the WebSocket by themselves where it doesn't connect.
To test a game server in your own tests, with no network and no waiting, `@zaisma/game-server/testing` runs it in a room in memory with players over links that delay, jitter, lose and stall what they carry, on a clock the test moves:
```ts
import { createTestRoom } from "@zaisma/game-server/testing";
const world = createTestRoom({ gameServer, delayMs: 75, jitterMs: 15, datagramLossPct: 1, tickLateMs: 20 });
const ana = world.join("ana"); // a stand-in for Zaisma.joinRoom()'s room, for your game's own code
world.run(1000); // a second of play: deliveries, the server's ticks, every player's frames
world.setStalled("ana", true, "down"); // her connection stalls; false passes on what waited, all at once
world.traffic("ana"); // the bytes and frames each way, to measure what a second costs
```
A mistake in your game server's code becomes a coded error in the game's logs, never a silent success, and the Node runner behaves the same as Zaisma's rooms. Versions follow semver: within 1.x the package only gains things.
- The game server, handler by handler: the "Multiplayer" section of the [README](https://github.com/zaisma/zaisma-sdk#multiplayer) and [`docs/DEVELOPER-API.md`](https://github.com/zaisma/zaisma-sdk/blob/main/docs/DEVELOPER-API.md).
- Every name and option follows [`docs/NAMING.md`](https://github.com/zaisma/zaisma-sdk/blob/main/docs/NAMING.md).
MIT licensed.
### Multiplayer
Games include the SDK with `<script src="_zaisma/v1.js"></script>` and call `await Zaisma.joinRoom()`. Its reference is its types, [`packages/sdk/zaisma.d.ts`](packages/sdk/zaisma.d.ts) (served beside it as `_zaisma/v1.d.ts`): every call, option, event and error code, explained. Save it beside your game's folder (uploads take no `.ts` files) and put `/// <reference path="../zaisma.d.ts" />` (and in JavaScript, `// @ts-check`) at the top of your script, and your editor and AI get errors instead of guesses. A room link (`zaisma.com/g/<game>?room=CODE`) drops friends into the same match, as guests or signed in. A game that needs a Zaisma account for multiplayer or the whole game (its `account_requirement` setting) gives guests no passes (`error.code === "account_needed"`), and its page asks them to sign in. Any game can ask a guest to sign in while it runs with `await Zaisma.player.signIn()`: the page offers an account beside the game, signing in happens in a new tab so the game keeps running, and the next `Zaisma.player.getPass()` or `joinRoom()` is the account's. Player passes come from the game's zaisma.com page, which checks that a real browser opened it (Cloudflare's invisible check, started as the page opens so Play doesn't wait), so bots can't fill rooms: a game opened anywhere else, or a browser the check can't confirm, can't join (`error.code === "unchecked"`).
Multiplayer is server-client: the *client* is the game in the browser, the *game server* holds the official state and checks every move, and a *room* is one live match running one copy of the game server. A game server is a plain object:
```ts
export default {
maximumPlayerCount: 8, // up to 100
ticksPerSec: 20, // up to 60; leave out for turn-based games so the room sleeps between moves
setup: (setupData) => ({ players: {} }), // setupData: what room.reserve() passed, for a room another room made, else null
onJoin(state, player, room, joinData, joinInfo) {}, // joinData: what the player's game passed to joinRoom({ joinData }), else null;
// joinInfo: { fromRoomCode, isReturning, isSpectator } (isReturning: back to a held seat)
canJoin(state, player, room, joinData, joinInfo) {}, // true lets them in; false or { refusalMessage } turns them away
onChat(state, player, room, chatInfo) {}, // a player's room.chat, before Zaisma's filter: true, false or { toPlayerIds }
adultChatFilterEnabled: false, // true: Zaisma's chat filter stops contact details between adults too (free)
onLeave(state, player, room, leaveInfo) {}, // leaveInfo.reason: left, lost, idle, hidden or kicked
onMessage(state, player, room, message) {},
onBytes(state, player, room, bytes) {}, // bytes a player's game sent (room.sendBytes), a Uint8Array
onTick(state, tickDurationSec, room) {}, // tickDurationSec: seconds since the last tick
onRequest(player, request, server) {}, // a request outside any room (Zaisma.server.request): answer it (below)
schedules: [{ name: "daily-reset", cron: "0 0 * * *" }], // runs by itself, in UTC (below)
onSchedule(run, server) {}, // run.name: which schedule is due
};
// room.broadcast(message, { exceptPlayerId, delivery }), room.send(playerId, message, { delivery }), room.players, room.end(message),
// room.broadcastBytes(bytes, { exceptPlayerId, fromPlayerId, delivery }), room.sendBytes(playerId, bytes, { delivery }),
// room.setListed(false), room.setOpen(false), room.reserve({ playerIds, setupData }),
// await room.database.query(sql, values), await room.database.batch([{ sql, values }]) (the game database, below)
// await room.verifyReceipt(receipt) (a purchase's signed receipt, checked; server.verifyReceipt the same)
// room.readDataFile("maps/docks.bin") (a data file beside the code, an ArrayBuffer; server.readDataFile the same; below)
```
Names follow [`docs/NAMING.md`](docs/NAMING.md): whole words, with the unit in the name. A game server with an option it doesn't take doesn't start, and says which ones it does take (`unknown_option`); the SDK refuses options and events it doesn't take the same way. Every message between a game and its room says its `type`, and a game's own messages travel in `data`; rooms count messages, not their size, so whole words cost nothing.
`canJoin` decides who comes in, before they join: answer `true` to let them in, `false` to turn them away, or `{ refusalMessage: "Wrong room password." }` to turn them away with a message they see (up to 200 characters). Any other answer, nothing included, like a string, turns them away too, and shows in your game server's errors with what to answer instead. Only decide there; change the state in `onJoin`.
```ts
canJoin(state, player, room, joinData) {
return joinData?.password === state.password || { refusalMessage: "Wrong room password." };
},
```
Each player's ping, measured by the room, is `room.pingDurationMs(playerId)` on the game server and `room.pingDurationMs` in their game, and both read the room's clock with `room.serverTimeMs()` (see "Room connections" in [`docs/DEVELOPER-API.md`](docs/DEVELOPER-API.md)).
A room takes up to 100 players at up to 60 ticks a second. Each player's game sends up to 30 messages a second (a burst of 60), so a game at 60 ticks sends two inputs in one message; the game server can still send every tick. Past 100 players, split a world into rooms and move players between them (`room.moveTo`).
**Bytes:** for snapshots and inputs where JSON is too big, a game sends bytes with `room.sendBytes(bytes)` (an `ArrayBuffer` or any typed array) and gets them with `room.on("bytes", (bytes, fromPlayerId) => {})`; the game server takes them in `onBytes` and sends them with `room.broadcastBytes(bytes)` and `room.sendBytes(playerId, bytes)`. `fromPlayerId` is the player they came from when the game server passes one player's bytes on (`room.broadcastBytes(bytes, { fromPlayerId: player.id })`, as the relay does), else `null`. Bytes have the same limits as messages: up to 16 KB each, counted together with them. The MCP's `get_stats` shows each game's room traffic per player and its biggest message types, with hints on what to send as bytes or send less.
**Sending only what changed:** turn on `stateSyncEnabled` and keep the world in the game server's state; each player then gets a full copy as they join and after that only what changed, after every tick (or every move, in a turn-based game), with no code to send it. `stateView(state, viewer, room)` cuts what each player sees: only what's near them in a big world, or without the other team's cards. In the game, `room.state` is the player's view and `room.smoothedState()` the same a moment (100 ms) behind, with positions moving evenly between updates. A player whose connection is backed up gets nothing until they've caught up, then a full copy. See `examples/arena`, and "State sync" in [`docs/DEVELOPER-API.md`](docs/DEVELOPER-API.md).
```ts
// A 100-player world where each player gets only the players within 800 units of them.
export default {
maximumPlayerCount: 100,
ticksPerSec: 30,
stateSyncEnabled: true,
setup: () => ({ players: {} }),
onJoin(state, player) { state.players[player.id] = { name: player.name, x: 0, y: 0, health: 100 }; },
onLeave(state, player) { delete state.players[player.id]; },
stateView(state, viewer) {
const me = state.players[viewer.id];
const nearby = {};
for (const [id, other] of Object.entries(state.players)) {
if (me && Math.hypot(other.x - me.x, other.y - me.y) <= 800) nearby[id] = { name: other.name, x: Math.round(other.x), y: Math.round(other.y), health: other.health };
}
return { players: nearby };
},
};
// In the game: requestAnimationFrame(function draw() { drawPlayers(room.smoothedState()?.players ?? {}); requestAnimationFrame(draw); });
```
**Messages that can be dropped:** `{ delivery: "latest_only" }` on any send, from the game server or the game, marks a message only the newest of matters, like positions every tick or where a player aims: while a player's connection is backed up, a newer one with the same `latestKey` (which it needs, like `"position"`) replaces it, and the newest goes once they catch up. Zaisma's rooms carry them over the WebSocket today, and the same call moves to real datagrams once Cloudflare carries them; on your own server, the fast lane already sends them as datagrams (see [Run your game server yourself](#run-your-game-server-yourself)). `get_stats` says which of your message types would gain from it (`latest_only_available`).
**Sending less, by default:** a room is billed for each message players send, so the SDK sends less without being asked. What a game sends at once (in one frame of its loop, say) goes as one message of up to 8, and each still reaches `onMessage` on its own, in order; sends also keep under the room's 30 a second by themselves, so a game sending more waits a few milliseconds and goes combined instead of hearing `too_fast`. A `latest_only` send that's the same as the last one with its `latestKey` isn't sent at all, since the room already has it; reliable sends always go. A game that needs every send to go alone and at once turns either off: `Zaisma.joinRoom({ sendCombiningEnabled: false, unchangedSkippingEnabled: false })`. Rooms on your own server combine from game server 1.40. Send input when it changes, not every frame, and use 20 to 30 ticks unless the game truly needs 60; `get_stats` says when players send more than a game needs (`input_frequent`).
Games without server code can use the built-in `relay` (up to 16 players), which passes each message on to everyone else as it was sent (your game's `message` event gets the message, then `fromPlayerId` as its second argument), and bytes the same way. See `examples/arena` (real-time) and `examples/four-in-a-row` (turn-based).
#### Your game server on Zaisma
Put your game server in a `zaisma-server/` folder at the top of your upload and set multiplayer to "Your game server" (dashboard), or `multiplayer: "own"` (MCP or API). Zaisma's rooms run it for you:
```
index.html
zaisma-server/
index.js export default { setup, onJoin, onMessage, ... }
physics.js import { step } from "./physics.js" works in index.js
levels/docks.js
maps/docks.bin a data file: room.readDataFile("maps/docks.bin")
```
- **Plain JavaScript ES modules:** `zaisma-server/index.js` default-exports the game server above, and can import the folder's other files by relative path: `.js` code, `.json` data (`import levels from "./levels.json"`) and `.wasm` WebAssembly, like a physics engine (`import mod from "./physics.wasm"` gives a `WebAssembly.Module`; `new WebAssembly.Instance(mod, imports)` starts it). Packages from npm (`import "lodash"`) and TypeScript need a build step: bundle into one `zaisma-server.js` at the top of the upload instead (`npx esbuild server.ts --format=esm --bundle --outfile=zaisma-server.js`), or into `zaisma-server/index.js` when it has data files. Up to 500 files and 64 MB in all, data files included, of which the code (`.js`, `.json` and `.wasm`) is up to 32 MB (`GAME_SERVER_LIMITS`).
- **Data files:** every other file in `zaisma-server/` (`.bin`, `.gz`, `.txt`, anything but `.js`, `.json` and `.wasm`) ships beside the code as a data file, like prebuilt navigation meshes, level geometry or a dictionary. `room.readDataFile("maps/docks.bin")` (or `server.readDataFile` in `onRequest`, `onSchedule` and `onWebhook`) answers it as an `ArrayBuffer`, by its path from `zaisma-server/`: no base64, no download, and nothing on the meter, since it comes with the code. It's the same `ArrayBuffer` every time, shared by every room of the version running in the same place, so read it and never change it; keep what you build from it in a variable outside the handlers (`const meshes = new Map()`) and every room there shares it too. A path with no data file throws a `GameServerError` `bad_room_call`. On your own server, data files are read from the game server's folder (`--data-folder`, or `startServer({ dataFolder })`; `zaisma-server` by default).
- **Time to start:** each call into the game server, a join, a request, has 50 ms of CPU (`GAME_SERVER_LIMITS.maximumCallCpuDurationMs`), as Cloudflare measures it, and a real-time room's ticks, each with the messages since the last one, go up to 30 to a call that shares 50 ms for each of them (1.5 seconds for 30, under Cloudflare's own stop). Cloudflare itself stops a call only at about 2 seconds, which freezes the match that long, so the room keeps the budget: when 20 of a room's calls within a minute go past theirs, the game server stops and the match ends, as for one that keeps failing, and its logs say so. A start has 5 seconds (`maximumStartCpuDurationMs`): loading the game server, `setup`, `onRestored`, and a real-time room's first tick after any of them, or after the room puts its state back in a fresh copy of the game server (one that started again and lost its memory, or one opened again after a stop), whether or not the game has `onRestored`, so build what the match needs once (a map's navigation, its collision) in that first tick, not spread over many. The game server's top-level code, outside its handlers, has Cloudflare's 1 second as it loads (`maximumLoadCpuDurationMs`), so heavy work goes in that first tick. One copy of the game server, shared by the version's rooms in one place, has 128 MB of memory (`maximumMemorySizeBytes`), its data files included: they load from storage into that memory when the copy starts, so with 64 MB of files about 60 MB is left for the matches. Every second of CPU is on the game's hosting meter, starts included.
- **Sealed off:** nothing of Zaisma's but its own game's database and secrets, and other servers only on the hosts you list (below), so it talks to its players through `room` and its answers to their requests. State is plain JSON.
- **Private:** players never get its files; the game domain refuses `zaisma-server/` and `zaisma-server.js`.
- **Real-time rooms batch input:** in a room with `ticksPerSec`, the state stays inside the sandbox, and players' messages and bytes reach `onMessage` and `onBytes` just before the next `onTick`, in the order they came, with what they send going out then (at most a tick later). A handler that throws leaves the rest of the batch to run, and what it changed in the state before throwing stays, as on your own server, where they run as they come. Either way a room's handlers run one at a time: one that awaits (the database, say) finishes before the room's next message, bytes or tick reaches the game server.
- **Kept in check:** an error in a handler loses that one message or tick and the match carries on. A call that runs past its CPU (above; a loop that never ends) is stopped, freezing the match meanwhile, and a match stopped twice ends. Your dashboard and the MCP's `get_stats` show these errors with the file and line they came from.
- **Memory outside the handlers:** a room's state is plain JSON, and it's all Zaisma keeps of a room. What the game server keeps in its own variables, outside the handlers (`const worlds = new Map()`), lives in the copy of the version that runs the room: the version's rooms running in the same place share it, as they share data files, and rooms elsewhere have copies of their own. It's lost whenever that copy starts again, which can happen at any time (a while unused, Zaisma's own updates, a call stopped for running too long), and then the room carries on from its last state, with no `onRestored` (that runs only when the room itself restarts): a turn-based room's state as of its last call, a real-time room's as of its last copy, taken every 5 seconds. So a world that isn't JSON (typed arrays, a collision tree, a physics engine's bodies) goes there, keyed by `room.roomCode`; each handler that finds its room's entry missing rebuilds it from the state, and the room deletes its entry once its match is over, since every room in that copy shares its 128 MB. On your own server and in play-locally, one process runs every room, so they all share it; it's lost when the process starts again (play-locally starts it again on each change to the game server, and when it goes over its 128 MB, as Zaisma's rooms do), and every room then comes back through `onRestored`.
- **Updates:** rooms keep the version they started with until they end; new rooms get the live version.
The same file runs on your own machine too (below), so you can test it there or move off Zaisma any time.
#### The game database
Every game has its own SQLite database, part of its hosting: shared by all its rooms, kept between matches, for what the game server owns or must trust (inventories, leaderboards, bans, worlds). Players' own progress belongs in cloud saves, which need no code. The game server uses it as `room.database` with plain SQL, in any handler that awaits it:
```js
async onJoin(state, player, room) {
await room.database.query("CREATE TABLE IF NOT EXISTS scores (player_id TEXT PRIMARY KEY, best_score INTEGER NOT NULL)");
const [mine] = await room.database.query("SELECT best_score FROM scores WHERE player_id = ?", [player.id]);
room.send(player.id, { bestScore: mine?.best_score ?? 0 });
},
async onMessage(state, player, room, message) {
if (message.type === "finished") {
await room.database.query(
"INSERT INTO scores VALUES (?, ?) ON CONFLICT (player_id) DO UPDATE SET best_score = max(best_score, excluded.best_score)",
[player.id, state.scores[player.id]],
);
}
},
```
- **`query(sql, values)`** runs one statement and answers its rows as objects (`[]` when it returns none). `values` fill its `?`s in order: text, numbers, `null` or a `Uint8Array` (whole numbers past 2^53 are refused with `bad_values` and can't be read back as numbers (`integer_too_large`): store them as text and read them with `CAST(col AS TEXT)`; use 1 and 0 for true and false; store objects as `JSON.stringify` and read them with `JSON.parse` or SQLite's JSON functions). To see what an `INSERT`, `UPDATE` or `DELETE` changed, add `RETURNING`.
- **`batch([{ sql, values }, ...])`** runs up to 100 statements in one transaction, so they all happen or none do (moving an item between two inventories, say), and answers each one's rows. `BEGIN` and `COMMIT` aren't taken; batch is the transaction.
- **Errors** are a `DatabaseError` with a `code` and a `fix`: `bad_sql` (SQLite's own message, or more than one statement in a query), `bad_values`, `integer_too_large` (a result holds a whole number past 2^53), `too_many_rows` (over 10,000 rows; page with `LIMIT`), `hosting_paused` (the game's hosting is paused this month, below), `database_full` (its storage, the database and kept rooms together, is at the 10 GB a game can have: it can change and delete rows but not grow) and `database_unavailable`.
- **Part of the game's hosting on Zaisma.** Rows written and read, and what it stores, count on the game's one hosting meter with its rooms and requests (see "Hosting" below). Every statement counts the rows SQLite touched, like Cloudflare's billing: an index makes lookups read fewer rows. When the game's hosting pauses, the database keeps answering for the hour running matches get, so their last saves land, then answers `hosting_paused` until it starts again.
- **You and your AI reach it too:** look at its tables and use, query it, fix data, change tables and roll it back to any minute in the last 30 days through the developer API, the MCP (`get_database`, `query_database`, `batch_database`, `restore_database`) or `zaisma database` in a terminal, with the same checks and limits (see "The game database" in [`docs/DEVELOPER-API.md`](docs/DEVELOPER-API.md)).
- **Take it out, bring it in:** the whole database goes out and in as SQLite's own SQL dump (`export_database`, `import_database`), or as a ready SQLite file from a terminal: `zaisma database export <game> game.sqlite` and `zaisma database import <game> game.sqlite`.
- **The same code on your own server:** the Node runner keeps the database in a local SQLite file (below), checked the same way, with no limits. Moving between Zaisma and your own server is one command each way: export to the file the runner uses, or import the runner's file.
#### Room browsing
Open rooms are listed on the game's page (how full each is and where it runs, never who's in it), with "playing now" under the title (every room counts, hidden ones too), and the game gets the same list to show its own way:
```js
const { rooms, playingPlayerCount, regions } = await Zaisma.rooms.list(); // how full each room is and where it runs, never who's in it
Zaisma.rooms.list({ region: "EU", labels: { Mode: "Classic" } }); // one region, or rooms with these labels
const room = await Zaisma.rooms.quickJoin(); // the linked room, else a busy room with space nearby, else a new one
Zaisma.joinRoom({ isListed: true }); // a new room others find in room lists (by default only its code and link reach it)
Zaisma.joinRoom({ name: "Ana's castle", labels: { Mode: "Classic", Map: "Docks" } }); // name and label a new room
await Zaisma.checkChat(typed); // { isAllowed, reason, message, hasSwearing, text }: Zaisma's chat check
```
Rooms can have a name and up to 4 labels (like Mode and Map), set by your game server with `room.setInfo({ name, labels })`, by the room's first player with the relay, or when the room is made. Names and labels players type are fine; on zaisma.com they show only if they pass Zaisma's text filter (no links, handles, emails, phone numbers or contact apps; no slurs or sexual words), and players can report them. Inside your game they're yours to look after, under the content rules.
On the game server, `room.setListed(false)` hides a room (its code and links still work) and `room.setOpen(false)` closes it to new players once a match starts; players who were in it can still come back. With the relay, the room's first player can do the same from the game (`room.setListed`, `room.setOpen`, `room.setInfo`). In the dashboard, a game lists its rooms on the page and in the game, only in the game, or nowhere.
Join on the game page is an ordinary room link, so the game decides what comes first:
- **Straight in:** call `joinRoom()` or `quickJoin()` when the game starts; both follow a link to a Zaisma room; on your own servers, join with `joinRoom({ serverUrl: Zaisma.rooms.linkedServerUrl, roomCode: Zaisma.rooms.linkedRoomCode })`, since only `joinRoom({ serverUrl })` follows a link that names a server.
- **A menu or character customizer first:** check `Zaisma.rooms.linkedRoomCode`, show your screen, then join with what the player picked: `joinRoom({ joinData: { character: "knight" } })` hands it to your game server's `canJoin` and `onJoin` (plain JSON, up to 4 KB; it comes from the player's browser, so check it like any message). If the room filled up meanwhile, `joinRoom` fails with `error.code === "room_full"` and `quickJoin` finds another.
- **Your own lobby:** list rooms only in the game and draw them yourself from `Zaisma.rooms.list()`.
#### Lobbies and matches
A room can make a room for some of its players and send them there, like a lobby starting a match:
```ts
const roomCode = room.reserve({ playerIds: [a.id, b.id], setupData: { map: "Docks", teams } }); // in your game server
```
```js
room.on("move", (move) => { room.leave(); move.join(); }); // in the game: go to the new room
```
The new room runs the same game server, and its `setup(setupData)` gets your setup data, so it can start the match already set up (players can read it but can't change it; up to 4 KB). It's ready before anyone hears its code, only the players named can join it (it's a closed room, until your server opens it), and it's hidden from room lists unless you pass `isListed: true` (with a `name` and `labels` if you like). To send players to a room that's already running instead, like the next area of an open world, use `room.moveTo(roomCode, { playerIds, joinData })`: the other room's `canJoin` decides, and `onMoved(state, moveResult, room)` hears `{ roomCode, movedPlayers, refusals }`. A room can reserve up to 20 rooms a minute. See `examples/four-in-a-row`: its "Find an opponent" waits in a lobby room until there's someone to play.
**Joining a friend without a reload.** When a player who is already playing picks another room of your game on Zaisma's page (a friend's Join, an invite), Zaisma asks the running game first. A room that handles moves takes it in place: `"move"` comes with `move.isAskedByPlayer` true (follow it unless your game can't leave now), or, without a `"move"` listener, a room listening for `"moved"` follows by itself. Otherwise, or when the player switches between playing and watching, the page reloads the game into the new room.
A griefed world or a bad update can be undone: `server.restoreKeptRoom(roomCode, { restoreToAt })` puts a kept room's world back as it was at any minute in the last 30 days, by your game's own rule of who may, and `server.undoKeptRoomRestore` undoes it for 30 days; `server.listKeptRoomRestores(roomCode)` gives a restore screen what it draws from. Players drop for a second or two and reconnect, and `onRestored` hears `restoreInfo.keptRoomRestore`, so your game tells them its own way. Your AI does the same through the API and MCP (`restore_kept_room`, `restore_every_kept_room`), and a deleted world comes back with `bring_back_kept_room` for about 28 days. See `docs/DEVELOPER-API.md`, Kept rooms.
**One room at a time.** A player sits in one of your game's rooms at a time, as on Steam: when they join another room, their seat in the first closes with "Joined from somewhere else" and your game server's `onLeave` runs there with reason `"left"`. Moving a player (`room.moveTo`, `room.reserve`) and watching (`isSpectator`) never close a seat. A game that keeps players in more than one room, like a hangout hub beside its matches, raises `maximumRoomCountPerPlayer` (up to 10): a join past it closes the oldest seat. "Playing now" counts each player once.
**Kept rooms** are for worlds that last, like a survival server: a kept room doesn't end when everyone leaves, but sleeps with its state saved, costs nothing while it sleeps, and wakes as it was when someone joins, a day or a month later.
```ts
room.setKept(true); // in your game server, like in setup or when players build their first base
```
A listed kept room stays on the game page's Rooms tab with nobody in it, like a server waiting for players (`Zaisma.rooms.list` says `isKept`). A world waking from its sleep runs `onRestored` with `restoreInfo.lostDurationSec` 0 and `restoreInfo.savedAt`, so you can grow crops for the time that passed, and it wakes on the game's live version, with `restoreInfo.savedVersionId` saying which one saved it. `room.end()` ends it for good, and `room.setKept(false)` makes it an ordinary room again. Saved worlds count toward the game's storage with its database, on its hosting meter: at the 10 GB a game can have, new rooms can't be kept until you make room, but kept rooms keep saving. List and delete them with `list_kept_rooms` and `delete_kept_room`, or `zaisma kept-rooms`. A room made with `room.reserve({ ..., isKept: true })` starts kept. On your own server the Node runner keeps them in `--room-state-file`.
`room.roomCode` tells the game server which room it's in, so a game with one shared world can keep only that room and turn players away from any other code, even from a changed page:
```ts
canJoin(state, player, room) { return room.roomCode === "WRLD22" || { refusalMessage: "Join the main world." }; },
onJoin(state, player, room) { room.setKept(true); },
```
Playing alone needs no room, so don't make one until others can join: time in a room counts toward hosting even with one player.
**Hosting.** Everything a game runs on Zaisma's servers (its rooms' awake time, connections and messages, its game server's CPU and starts, data Zaisma's relay sends its players, its database, and requests and schedule runs to its game server) counts on one meter, and every game gets a free allowance each month (UTC): 8 friends playing a real-time game every night use about a third of it, and it covers about 1,300 player-hours of an 8-player real-time game. Your dashboard and `get_stats` show it as a percentage, with what used it. Past it, a game keeps going only when its developer has added hosting credit and given it a monthly budget (`monthly_budget_cents`; see "Hosting and credit" in [docs/DEVELOPER-API.md](docs/DEVELOPER-API.md)). Otherwise its hosting pauses until the month resets: no new rooms open (joining fails with `error.code === "hosting_paused"`), no new relayed connections or requests start, and matches already running get an hour to finish (`room.endsAt`, the game server's `onEnding`, the SDK's `ending` event). Game files, saves, sign-in, publishing and spectators are never on the meter, and your own servers never are.
#### Spectators
A game server that turns watching on lets people watch a match without playing, like a tournament's crowd or friends waiting for the next round:
```ts
export default {
maximumSpectatorCount: 20, // up to 100; leave it out, or 0, and nobody can watch
onSpectatorJoin(state, spectator, room) { room.send(spectator.id, { type: "snapshot", state }); }, // catch them up
onSpectatorLeave(state, spectator, room) {},
onTick(state, tickDurationSec, room) {
room.broadcast({ type: "positions", positions: state.positions }); // players and spectators
room.broadcast({ type: "hands", hands: state.hands }, { audience: "players" }); // never the spectators
room.broadcast({ type: "commentary", text: state.commentary }, { audience: "spectators" });
},
};
```
```js
const room = await Zaisma.joinRoom({ isSpectator: Zaisma.rooms.isLinkedAsSpectator }); // in the game
room.isSpectator; // watching: room.send and room.sendBytes throw error.code "spectator_cannot_send"
room.spectatorCount; // how many watch; the "settings" event says when it changes
```
A spectator gets everything the room sends everyone (`audience` picks who: `"everyone"`, the default, `"players"` or `"spectators"`, for `room.broadcast` and `room.broadcastBytes`), and `room.send(spectator.id, ...)` reaches one. They send nothing, so they can't bother players or dodge the room's limits; they're never in `room.players`, don't count toward `maximumPlayerCount` or "playing now", are never idle or away, and are free: watching isn't player time. `room.spectators` lists them, `joinInfo.isSpectator` tells `canJoin` a watcher is asking, and `room.kick` works on them too. A closed or full room can still be watched (watching a match under way is the point); a room with nobody playing can't (`room_not_running`), one whose audience is full answers `spectators_full`, and a player already playing in the room answers `already_playing`. When the last player leaves, the spectators are told the match ended.
On zaisma.com, Watch shows beside Join (friends playing, the Players plate, the Rooms tab) for games that take spectators, with the same rules as Join, and opens the game with `Zaisma.rooms.isLinkedAsSpectator` true. The Rooms tab and the Players plate say how many are watching, never who.
#### Players who walk away
Players who walk away stop holding seats and running matches, in every game, with no code:
- **Lost connections** (a closed laptop, lost signal): the SDK pings the room every 25 seconds without waking it, and a connection that stops answering is dropped about a minute later (within seconds in a real-time room). The SDK says goodbye as the page closes, so most players leave at once.
- **Idle:** after 10 minutes without input the SDK asks "Still there?" with a small plate at the top of the game for 30 seconds; no answer, and the player walks away. Rooms check for themselves too: a game that sends nothing at all for a minute past that counts as idle.
- **Hidden:** in a real-time room (one with `ticksPerSec`), a game hidden for 2 minutes counts as away.
A player whose connection drops stays in the match first, as away with reason `lost`, for 30 seconds while the SDK reconnects: `onAway` runs if your game server has one, every player's game sees `awayReason: "lost"` for them in `room.players`, and if they're back in time, `onBack` runs and they carry on where they were. Freeze their character meanwhile (in `onTick`, skip players whose `room.awayReason(playerId)` is `"lost"`), or do nothing and they stand still.
A player who walks away, or whose connection stays lost, leaves the match (`onLeave` with `leaveInfo.reason`) and the room holds their seat for 5 minutes: they come straight back to it with any input, or by reconnecting, and `onJoin` gets `joinInfo.isReturning`. Held seats count toward `maximumPlayerCount`, but players who walked away don't count as playing now or toward how full a room looks, and a room where everyone's away stops ticking. Once the seat runs out, the SDK offers their old room again if it has space. Zaisma never covers your game or sends anyone away from it for being idle.
When Zaisma restarts its rooms (every update to Zaisma does), a real-time match comes back where it was a few seconds before, and its players reconnect into it: the room saves its state every `stateSaveIntervalSec` (5 by default, 1 to 60), and `onRestored(state, restoreInfo, room)` runs once with `restoreInfo.lostDurationSec`, the seconds of play lost, so you can resync clocks or tell your players. Turn-based rooms save after every move, so they lose nothing. Publishing with `match_update_mode: "now"` moves every live match to the new version the same way, within seconds; your game server can hold it until the end of a round with `onVersionUpdate` ([Updates](docs/DEVELOPER-API.md#updates)). A room that never ends (a kept world, a lobby) hears of a `next_match` version with `onVersionAvailable`, within about a minute, and moves to it at a break of its own with `room.applyVersionUpdate()`. After a switch that reloads it, a game knows why: `Zaisma.page.reloadReason` is `"version_update"` (or `"player"` for the player's own reload, `null` on a first load), and `Zaisma.page.previousRoomCodes` lists the rooms it was in, to join each again.
Your game server picks what happens:
```ts
export default {
idleCheck: "server", // who checks: "server" (the default), "client" (each player's game decides), or "off"
idleTimeoutSec: 300, // seconds without input before "Still there?" (default 600)
seatHoldDurationSec: 120, // seconds a seat stays held (default 300, up to 1800; 0 for none)
reconnectTimeoutSec: 30, // seconds a player whose connection dropped stays in the match (default 30, up to 300; 0 to take them out at once)
maximumRoomCountPerPlayer: 1, // rooms of your game one player sits in at once (default 1, up to 10; see "Lobbies and matches")
awayMode: "lobby", // send players who walk away back to the room that made this one (room.reserve); "hold" is the default
onAway(state, player, room, awayInfo) {}, // awayInfo.reason "idle", "hidden" or "lost"; for idle and hidden, the player stays and you kick, move or keep them
onBack(state, player, room) {}, // a player onAway kept, or whose connection dropped, came back: send them the full state
stateSaveIntervalSec: 5, // how often a real-time room saves its state, for a restart to come back with (default 5, 1 to 60)
onRestored(state, restoreInfo, room) {}, // the room restarted with its saved state: restoreInfo.savedAt, lostDurationSec and savedVersionId
onVersionUpdate(state, versionUpdate, room) {}, // a version published "now" is coming: call room.applyVersionUpdate() at a good moment, or it switches at versionUpdate.appliesAt
onVersionAvailable(state, versionAvailable, room) {}, // a version published "next_match" is live while this match runs on: room.applyVersionUpdate() moves to it, for a room that never ends
onPurchase(state, player, room, purchase) {}, // with purchase_delivery "game_server": a purchase to hand over, once; a throw tries again at the player's next join
onRefund(state, player, room, purchase) {}, // a purchase handed over before was refunded or charged back: take back what you decide
};
```
In the game, all of it is optional:
```js
room.on("connectionStatus", (connectionStatus) => {}); // the socket: "connecting", "open", "reconnecting" or "closed"
room.on("away", ({ awayReason, seatHoldDurationSec }) => {}); // awayReason: "idle" or "hidden" (also room.awayReason); the seat is held that long
room.on("idle", ({ idleStatus }) => {}); // ask "Still there?" your way: "asking", then "answered" or "timed_out"
room.on("back", (back) => back.rejoin()); // back: isSeatHeld true, already in; false, the seat ran out and listening turns off rejoining by itself
room.on("players", (players) => {}); // each player's awayReason: "lost" while their connection dropped, "idle" or "hidden" if onAway kept them, else null
Zaisma.joinRoom({ idleCheckEnabled: false }); // no "Still there?" in this game (where idleCheck is "client", as with the relay, the room follows this)
```
Every number behind this (pings, timeouts, reconnecting, held seats, message limits, close codes) is in [Room connections](docs/DEVELOPER-API.md#room-connections).
Your own clients follow the same protocol: send the text `ping` every 30 seconds or so (the room answers `pong`), `{"type":"idle"}`, `{"type":"hidden"}` and `{"type":"shown"}` as they happen, and `{"type":"back"}` when the player returns. Their hello carries `"protocolVersionNumber":1`. Errors from the room are `{"type":"error","code":"room_full","message":"This room is full."}`, with codes in lowercase snake_case, one of: `rented_share_used`, `room_full`, `room_closed`, `ended`, `too_big`, `too_fast`, `bad_message`, `bad_pass`, `bad_player_token`, `no_hello`, `not_allowed`, `game_unavailable`, `busy`, `kept_out`, `refused`, `room_not_running`, `hosting_paused`, `account_needed`, `game_not_open_to_player`, `blocked_player_here`, `other_version`, `spectators_full`, `spectator_cannot_send`, `already_playing`, `bad_origin`, `send_queue_full`, `chat_not_here`, `voice_not_here`, `chat_not_allowed`, `chat_empty`, `chat_too_long` or `chat_too_fast`. The SDK's types explain each one (`RoomErrorCode`); codes only grow within v1.
#### Requests to your game server
Not everything needs a room. A game's own game server can also answer plain requests from the game, for a leaderboard, a shop or a daily reward, in single-player games too. Give it `onRequest`, and the game calls it with `Zaisma.server.request`:
```js
// zaisma-server/index.js (or zaisma-server.js)
export default {
async onRequest(player, request, server) {
await server.database.query("CREATE TABLE IF NOT EXISTS rewards (player_id TEXT PRIMARY KEY, claimed_date TEXT NOT NULL)");
if (request.type === "claimDailyReward") {
const today = new Date().toISOString().slice(0, 10);
const [claimed] = await server.database.query("INSERT INTO rewards VALUES (?, ?) ON CONFLICT (player_id) DO UPDATE SET claimed_date = excluded.claimed_date WHERE claimed_date < excluded.claimed_date RETURNING player_id", [player.id, today]);
return { isClaimed: Boolean(claimed) };
}
return { error: "unknown request" };
},
};
// In the game:
const { isClaimed } = await Zaisma.server.request({ type: "claimDailyReward" });
```
- **`onRequest(player, request, server)`** answers what the game gets back: plain JSON, up to 1 MB, within 10 seconds. `player` is who sent it, from their player pass, so a player can't claim someone else's reward. `request` is the game's plain JSON, up to 16 KB, from the player's browser, so check it like any message and say what it's for in its `type`. There's no room and no state: what lasts goes in `server.database`, the same game database the game's rooms use.
- **Rooms or not:** a game server with only `onRequest` needs no `setup()` and runs no rooms; one with both does both. Requests work whatever the game's multiplayer setting, as long as its live version has the game server in its `zaisma-server/` folder or `zaisma-server.js`, run in the same sealed sandbox as its rooms.
- **Errors:** the game gets an `error.code`, one of: `rented_share_used`, `bad_request`, `too_big`, `bad_pass`, `bad_player_token`, `account_needed`, `game_not_open_to_player`, `game_unavailable`, `no_request_handler`, `game_server_error`, `hosting_paused`, `slow_down`, `bad_origin` or `busy`. `no_request_handler` means no `onRequest`; `game_server_error` means it threw, answered something that isn't plain JSON or over 1 MB, or took over 10 seconds (you see why with your game server's errors in the dashboard and `get_stats`, with the file and line); `slow_down` means over about 120 a minute from one address; `hosting_paused` answers HTTP 403. The pass's own are `account_needed` and `bad_pass`; `bad_player_token` is your own server's, for a game played off Zaisma (below). A game server that keeps running on too long (a loop that never ends) is paused for a few minutes.
- **Part of the game's hosting on Zaisma.** Each request, webhook event and schedule run counts on the game's hosting meter, and so does its CPU past the first 10 ms (see "Hosting" above). While the game's hosting is paused, requests answer `hosting_paused`. Your dashboard and `get_stats` show the month's count.
- **On your own server** the Node runner answers the same requests at `POST /v1/requests/<game>` on its port, with `server.database` its local SQLite file: `Zaisma.server.request(request, { serverUrl: "https://play.example.com" })`. Any server can answer them the same way: the body is `{ pass, request }` as JSON (sent as `text/plain`, so browsers need no preflight), and the answer `{ answer }` or `{ error: { code, message } }`.
#### Schedules
A game's own game server can also run by itself, for a daily reset, a weekly leaderboard or a persistent world's turns. List its `schedules`, each a name and a cron, and `onSchedule` runs at each:
```js
// zaisma-server/index.js (or zaisma-server.js)
export default {
schedules: [
{ name: "daily-reset", cron: "0 0 * * *" }, // every midnight, UTC
{ name: "world-turn", cron: "*/15 * * * *" }, // every 15 minutes
],
async onSchedule(run, server) {
if (run.name === "daily-reset") {
// Safe to run twice: it only resets what's older than this run.
await server.database.query("DELETE FROM daily_scores WHERE scored_at < ?", [run.scheduledAt]);
}
if (run.name === "world-turn") await server.database.query("UPDATE crops SET growth = min(growth + 1, 10)");
},
};
```
- **`cron`** is the usual five fields, minute hour day-of-month month day-of-week, always in UTC: numbers, `*`, ranges (`1-5`), steps (`*/15`) and lists (`1,15`). `"0 4 * * 1"` is Mondays at 04:00. So a schedule runs at most once a minute; anything faster belongs in a room's `onTick`. A cron that doesn't read stops the game server starting, and says why.
- **`onSchedule(run, server)`** gets `run.name`, `run.cron` (the cron with spaces tidied: trimmed, one space between fields) and `run.scheduledAt`, the minute it was due (an ISO time). There's no room, no player and no state: what lasts goes in `server.database`, the same game database the game's rooms and requests use. It has 30 seconds. A run can rarely come late or twice (after a restart), so make it safe to repeat, like a reset that checks `run.scheduledAt`.
- **Up to 10 schedules on Zaisma.** Each run counts as a request on the game's hosting meter, and a paused game's schedules don't run. They run with the live version's game server, whatever the multiplayer setting, within a minute of it going live; a version without them stops them, and so does a game taken down. A game server with only schedules needs no `setup()` and runs no rooms. Your dashboard and `get_stats` show each schedule with its next and last run, the runs per day, and any errors with the schedule's name, file and line.
- **On your own server** the Node runner runs the same schedules at the same minutes while it's up, with `server.database` its local SQLite file, and prints a run's errors. A run due while it's down is missed.
#### Messages between rooms
A game server reaches the game's other live rooms with a room message: `room.sendToRoom(roomCode, message)` tells one room (answering `{ isDelivered }`), `room.sendToEveryRoom(message, { labels })` tells every other room with someone in it, or only those holding every label given (answering `{ roomCount }`), and `room.listRooms({ labels })` lists them, newest first. Outside rooms, `onRequest`, `onSchedule` and `onWebhook` get the same on `server`, plus `server.getRoom(roomCode)` (the room and who's in it), `server.kickFromRoom(roomCode, playerId, { message, keepOut })` and `server.endRoom(roomCode, message)`. The receiving room's `onRoomMessage(state, roomMessage, room)` decides what its players see; without it, every player's game hears the room's `roomMessage` event. `roomMessage.senderKind` says who sent it (`room`, `server` or `developer`), with `fromRoomCode` for a room. A message is plain JSON up to 16 KB; a room sends up to 20 a second and takes up to 100, and the whole game sends to every room up to 10 times a minute.
A party leaving one world for another, the same code in Zaisma's rooms and on your own server with the Node runner:
```js
export default {
setup: () => ({ partiesComing: [] }),
async onMessage(state, player, room, message) {
if (message.kind !== "travel") return;
const { isDelivered } = await room.sendToRoom(message.toRoomCode, { kind: "party_coming", leaderName: player.name });
if (isDelivered) room.moveTo(message.toRoomCode, { playerIds: [player.id] });
},
onRoomMessage(state, roomMessage, room) {
if (roomMessage.message.kind !== "party_coming") return;
room.broadcast({ kind: "notice", text: `${roomMessage.message.leaderName}'s party is on its way from ${roomMessage.fromRoomCode}.` });
return { ...state, partiesComing: [...state.partiesComing, roomMessage.fromRoomCode] };
},
};
```
On Zaisma, the developer API and MCP reach the same rooms (`send_room_message`, `send_to_every_room` now or at a set time, `list_rooms`, `get_room`, `kick_player`, `end_room`), for the game's own moderation page or a live event: see "Reaching live rooms" in [`docs/DEVELOPER-API.md`](docs/DEVELOPER-API.md). On your own server the Node runner gives these calls among its own rooms, and Zaisma's API doesn't reach them.
#### Calling other servers, with secrets
A game's server can call your own server, a payment provider, Discord, GitHub or any other https API with plain `fetch()`, on the hosts you list for the game, and keep the tokens it needs as secrets:
```js
// zaisma-server/index.js: post each new top score to the game's Discord channel
export default {
async onRequest(player, request, server) {
if (request.type !== "score") return null;
await fetch(server.secrets.DISCORD_WEBHOOK_URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ content: `${player.name} scored ${request.score}!` }),
});
return { isPosted: true };
},
};
```
```sh
## Room connections
How a room and each player's game stay in touch, the same in Zaisma rooms and on your own server (the Node runner): how a dead connection is noticed, what happens to a player whose connection drops or who walks away, the limits on what players send, and why a connection closes.
### Staying connected
- **The SDK pings** the room every 25 seconds (the room answers without waking up), and reconnects by itself when a ping goes unanswered for 15 seconds, or in a real-time room (one with `ticksPerSec`) after 8 seconds without a word from the room, which probes every 2 seconds (not while the player is away or the game is hidden).
- **Reconnecting** waits half a second, then doubles each try up to 8 seconds, with no limit, and `room.connectionStatus` is `"reconnecting"` meanwhile. Your game keeps the same room object: the `players` event and your game server's messages carry on once it's back.
- **The room drops** a connection with no ping or message for 75 seconds (a closed laptop, lost signal): Zaisma rooms check when one is due (a connection's 75 seconds, an idle player's time, a held seat), sleeping in between, the Node runner every 5. The SDK says goodbye as the page closes, so most players who leave do so at once.
- **`room.connectionStatus` is the socket only:** `"connecting"`, `"open"`, `"reconnecting"` or `"closed"`. Whether the player is in the match is `room.awayReason` (below), so a player who walked away with the socket still open stays `"open"`.
- **Sends wait while it's down:** reliable `room.send` and `room.sendBytes` calls made while `connectionStatus` isn't `"open"`, or while the player is away, are kept in order and go once the room lets them back in, before any latest-only sends that waited. Up to 60 wait (the room's burst, so the flush never trips `too_fast`); past that the oldest is dropped and the `error` event says `send_queue_full` once per outage. Both calls return `false` only once the room is gone (ended, kicked or left).
### Dropped players
A blip is the most common thing that goes wrong online, so a player whose connection drops stays in the match for a while instead of leaving it:
- **Away, reason `lost`:** the player stays in `room.players` for `reconnectTimeoutSec` (30 by default, 0 to 300). The game server's `onAway(state, player, room, { reason: "lost" })` runs if it has one, `room.awayReason(playerId)` answers `"lost"`, and every player's game sees `awayReason: "lost"` for them in `room.players` and the `players` event. They don't count as playing, nothing is sent to them, and their seat counts toward `maximumPlayerCount`. If they were the host, the next player is host until they're back.
- **Freeze them:** a game that does nothing shows them standing still. A real-time game can freeze their character, skip their turn or pause the match: in `onTick`, skip players whose `room.awayReason(playerId)` is `"lost"`, and in the game, draw them dimmed or "reconnecting" from `awayReason`.
- **Back in time:** the SDK reconnects by itself, `onBack(state, player, room)` runs (not `onJoin`, and `canJoin` isn't asked), and `awayReason` goes back to `null` for everyone. Send them the full state in `onBack`, since they missed what was sent meanwhile.
- **Not back in time:** they leave the match as before: `onLeave` with reason `lost`, and the room holds their seat for `seatHoldDurationSec`, so a later return gets `onJoin` with `joinInfo.isReturning`.
- **`reconnectTimeoutSec: 0`** takes a dropped player out of the match at once (`onLeave`, reason `lost`), as before this option.
- **`onAway` takes over idle and hidden too:** with `onAway`, a player who goes idle or hidden stays in the room until your game decides (below). To freeze dropped players while leaving idle and hidden ones to the room, read `room.awayReason` in `onTick` instead of adding `onAway`; `onBack` alone changes nothing else.
Real-time rooms notice a silent drop within seconds (their probes); turn-based rooms keep the slower 75-second check, so they can sleep between moves.
### Updates
A version you publish (or roll back to) reaches running matches at their next match, or now: `match_update_mode` `"next_match"` (the default) or `"now"` on `publish_version`, on `upload_files` and `POST /games/:slug/versions` with `publish_when_approved`, `zaisma publish --match-update-mode now`, `zaisma upload … --publish-when-approved --match-update-mode now`, or Update running games now on the dashboard.
**Now is the rough way.** Every live room saves, its players drop for a few seconds and their games reload; each match goes on from its last save, a few seconds back, on the new version, so a match your game server can't read in `onRestored` is lost, and one kept only in players' games starts over. The dashboard says so beside Update running games now, with how many players are in a room right now (`in_room_player_count` on `GET /games/:slug` and `get_game`), and `zaisma publish` says the same before it goes. Keep it for a fix live matches need at once (an exploit, a crash). The smoother way: the default `next_match`, `onVersionUpdate` to switch a match at a natural break, and `Zaisma.versions` so a game not in a match switches when it says.
- **Now, in a match:** every live room of the game hears it within seconds (a room that slept through it finds it within a minute of waking). Players' games get the room's `versionUpdate` event, `{ versionId, appliesAt, isReloading }`, to show a countdown or save. Without `onVersionUpdate`, the match switches 10 seconds later. With `onVersionUpdate(state, versionUpdate, room)`, the room waits for your game server: call `room.applyVersionUpdate()` at a good moment, like the end of a round, or it switches at `versionUpdate.appliesAt`, 5 minutes on.
- **The switch:** the room saves, its connections close with code `4004`, and the new version's game server starts from the saved state: `onRestored(state, restoreInfo, room)` runs with `restoreInfo.savedVersionId`, the version that saved it, so you can bring an older state up to date (or `room.end()` the match if you can't). When only the game server changed, players' games reconnect by themselves in a second or two. When the game's own files changed (`isReloading`), the game page reloads the game in place at the new version, with its save, and `Zaisma.joinRoom()` with no code brings the player back into the same room. Players come back as dropped players do (away, reason `lost`, for `reconnectTimeoutSec`, then a held seat), so a slow reload still finds its place. The game page's bar says Updating meanwhile; nothing covers the game.
- **Now, not in a match** (a single-player game, or a menu): never forced. The game page notices within 2 minutes. A game listening to `Zaisma.versions.on("update", (update) => …)` switches when it says, with `update.apply()` (at a checkpoint, back at its menu), and the page reloads it with its save; otherwise the bar beside the game shows Update, and the player taps it when they're ready, or gets the new version the next time they open the game.
- **Next match:** nothing changes for running matches: a room keeps the version it started on until its match ends. A room that never ends (a kept world, a lobby) can move anyway: its game server's `onVersionAvailable(state, versionAvailable, room)` hears the version within about a minute of the publish, `{ versionId, isReloading }`, and `room.applyVersionUpdate()` then switches it as a `now` update does, at a moment the game picks.
- **A room on another version:** a player always plays the version their room runs. A Zaisma room whose game server runs another version than the player's game (an open tab from before a publish, or a friend's match still finishing on the version before) turns a newcomer away with `other_version`, and on the game's Zaisma page the game reloads at the room's version, with its save, and joins it; your game never sees it. While the room runs it, the game's address serves that version's files to the room's players, as long as it's one you could roll back to (the live version and the last 5 that passed), and not held or taken down. Players already in the room are never turned away this way, and rooms with a built-in game server have no version of their own. Outside Zaisma, through a tester link, or when that version is no longer kept, the join fails with `other_version`.
- **After a reload,** a game knows why: `Zaisma.page.reloadReason` is `version_update` when an update reloaded it, `player` for the player's own reload and `null` on a first load, and `Zaisma.page.previousRoomCodes` lists the rooms it was in, to join each again.
- **On the bench,** `POST /bench/api/version-updates` plays either mode on your own computer.
- **On your own server** `onVersionUpdate` and `onVersionAvailable` never run and `room.applyVersionUpdate()` does nothing: the game page still reloads players' games after a `now` publish when they're not in a match, and you restart your server to switch it (the Node runner brings its matches back, below).
### Restarts
Zaisma restarts its rooms whenever Zaisma itself is updated, and a match carries on:
- **Saved every few seconds:** a real-time room saves its game server's state every `stateSaveIntervalSec` (5 by default, 1 to 60), only when it changed, and once more when everyone walks away or leaves; a turn-based room saves after every change, as always. A state over 32 MB as JSON isn't saved: the game's logs say so once, and a restart starts that room fresh.
- **Back a few seconds behind:** the restarted room starts from the last save instead of `setup`; a real-time room (one with `ticksPerSec`) also runs `onRestored(state, restoreInfo, room)` once, and so does a turn-based room that had players in its match (it loses no moves, only the connections): `restoreInfo.savedAt` (an ISO time) and `restoreInfo.lostDurationSec`, the seconds of play since then that are lost. Use it to resync clocks or tell players.
- **Players come back as dropped players:** everyone who was in the match is away with reason `lost` (`room.awayReason` answers it in `onRestored`), `onAway` runs for each, and they have the whole `reconnectTimeoutSec` from the restart. Their connections drop (the Node runner closes them with code `1012` as it stops), the SDK reconnects to the same room by itself, and `onBack` runs for each one back; anyone who isn't leaves as `lost` (above).
- **A room that empties** keeps its saved state for a day, so players rejoining it find the match as it was (a real-time room's `onRestored` runs then too, with `lostDurationSec` 0: it saved as the last player left). A kept room keeps it until it ends (see Kept rooms below). A match that ends keeps nothing.
- **On your own server** the Node runner saves to its `--room-state-file` (`zaisma-room-states.sqlite`) the same way, and saves every room when it's stopped, so a clean restart loses nothing.
### Walking away
Players who walk away stop holding seats and running matches, with no code:
- **Idle:** after `idleTimeoutSec` without input (600 by default, 30 to 86400), the SDK asks "Still there?" for 30 seconds; no answer, and they walk away (`idleCheck`: `"server"`, the default, `"client"` or `"off"`).
- **Hidden:** in a real-time room, a game hidden for 2 minutes counts as away.
- **What happens:** with `awayMode: "hold"` (the default), they leave the match (`onLeave`, reason `idle` or `hidden`) and the room holds their seat for `seatHoldDurationSec` (300 by default, up to 1800, 0 for none); any input brings them back, and `onJoin` gets `joinInfo.isReturning`. `awayMode: "lobby"` sends them to the room that made this one (`room.reserve`). With `onAway`, they stay in the room and your game decides: kick them, move them or keep them.
- **In the game:** the `idle` event hands `{ idleStatus, answerTimeoutSec }`: `"asking"` when it's time to ask (listening replaces Zaisma's "Still there?" plate), then `"answered"` on input or `"timed_out"` as the room hears they walked away. The `away` event hands `{ awayReason, seatHoldDurationSec }` and `room.awayReason` says `"idle"` or `"hidden"` until they're back. The `back` event hands `{ roomCode, isSeatHeld, rejoin() }`: `isSeatHeld: true` once the room let them back into their held seat; `false` on their first input after the seat ran out, when listening for `back` leaves rejoining to your game (`back.rejoin()`), and without a listener the SDK rejoins by itself.
### Message limits
- **From each player:** up to 16 KB a message (or bytes), and 30 a second with a burst of 60. The SDK throws `too_big` before sending one over 16 KB; past the rate, that message is refused with an `error` event (`too_fast`) and the connection stays open.
- **Who sent it:** a message or bytes the game server passes on from one player carries `fromPlayerId` (its send options' `fromPlayerId`; the relay always sets it), and the game's `message` event hands `(message, fromPlayerId)`, `bytes` hands `(bytes, fromPlayerId)`, with `null` for the game server's own.
- **Join and setup data:** up to 4 KB of JSON (`joinData`, `setupData`).
- **From the room:** what your game server sends isn't capped, but a player who can't keep up is dropped (below).
### Ping and the room's clock
- **Ping:** the game server reads a player's round trip with `room.pingDurationMs(playerId)`, and the player's game reads its own with `room.pingDurationMs`: the same number, in milliseconds, smoothed so one slow packet doesn't make it jump. It's `null` until the first measurement, right after the player joins.
- **Measured by the room:** the room sends each player a small probe right after they join, every 2 seconds while a real-time room ticks (turn-based rooms keep sleeping between moves), and whenever 256 KB has gone out to them; the SDK answers it at once. Answers aren't game messages: they don't count toward a player's 30 a second, your message stats or the idle check. Since the room measures it, a player can only make their ping look worse by answering late, never better, so cap any lag compensation that uses it.
- **One clock:** `room.serverTimeMs()` is the room's clock now, in epoch milliseconds, on the game server (like `Date.now()`) and in every player's game, where the SDK estimates it from the probes. A time the game server sends means the same moment for everyone, like `{ startsAtMs: room.serverTimeMs() + 3000 }` for a countdown.
### Slow connections
A player whose connection can't keep up is dropped before the room has to hold a growing backlog for them: when a probe has gone unanswered for 8 seconds, or 2 MB has gone out to them since the last probe they answered. Their connection closes with code `4003` and they become a dropped player (above): away with reason `lost` for `reconnectTimeoutSec`, while the SDK reconnects by itself, so they come back caught up. Send a returning player the full state in `onBack`, and in `onJoin` when `joinInfo.isReturning`, not just what changed (state sync does it by itself). A room's memory for its players stays bounded, and one bad connection can't stall a match for everyone else.
Before that, a connection can be **backed up**: 64 KB or more sent to it and not through yet. On your own server, that's the socket's `bufferedAmount`; in Zaisma rooms, 64 KB or more sent since the last probe the player answered, while a probe of theirs is 250 ms later than their ping. State sync skips a backed-up player and latest-only messages wait for them (below), so a slow player never builds a queue of stale updates.
### State sync
An optional building block for real-time worlds, the same in Zaisma rooms and on your own server: your game server keeps its state as a plain object, and with `stateSyncEnabled: true` each player's game gets it without your code sending anything.
- **A full copy, then what changed:** a player gets their whole view as they join (and after reconnecting), then, after each tick (or each handler, in a turn-based game), only what changed since their last: `{ type: "state", serverTimeMs, full }`, then `{ type: "state", serverTimeMs, changes }`. Each change is `[path, value]` (set) or `[path]` (remove), with `path` the keys and indexes from the top: objects by key, arrays by index while their length stays the same and whole when it changes. `serverTimeMs` is the room's clock as it was sent. Nothing goes out when nothing a player sees changed.
- **Each player's view:** `stateView(state, viewer, room)` answers what `viewer` sees, like only what's near them in a big world or without the other team's hand; without it, everyone sees the whole state. It runs for every player on every tick, so keep it cheap, and it only answers: a call in it that changes the room or sends (`room.broadcast`, `room.kick`, `room.end`, ...) throws `room_call_unavailable`, which the game's logs show; reading (`room.players`, `room.roomCode`) works. A view over 1 MB as JSON isn't sent, and the game's logs say so once.
- **In the game:** `room.state` is this player's view (null until the first update), the `"state"` event hands `(state, changes)` (`changes` null after a full copy), and `room.smoothedState({ delayMs })` answers the state `delayMs` (100 by default, up to 1000) behind the room's clock, between the two updates around then: numbers blended in a straight line (integers in between come back as fractions, and an angle that wraps blends the long way), anything else as the older one had it. Predicting the player's own moves stays your game's.
- **Backed up:** a player whose connection is backed up gets nothing until they've caught up, then a full copy, so a slow spell costs one copy instead of a growing queue. There are no acknowledgements: over the room's connection a change can't be lost.
- **Where it runs:** where the state is, in your game server's sandbox on Zaisma (its time counts as the game server's CPU) and in the room on your own server. The state goes as JSON, so keep it plain; its updates count as `(state)` in `get_stats`.
### Latest-only messages
`room.broadcast`, `room.send`, `room.broadcastBytes` and `room.sendBytes` on the game server, and `room.send` and `room.sendBytes` in the game, take `{ delivery, latestKey }`:
- **`delivery: "reliable"`** (the default) reaches every player, in order.
- **`delivery: "latest_only"`** may be dropped: while a player's connection is backed up, a newer latest-only message with the same `latestKey` replaces the one waiting, and the newest goes once they catch up (oldest key first, before anything newer). For positions sent every tick, or where a player aims. A player keeps up to 64 waiting, one per key; past it, the least recently replaced is dropped.
- **`latestKey`**, up to 40 characters, says which messages replace each other, like `"position"`, and `latest_only` needs one: without it the send throws: in the game (the SDK) the error's code is `bad_send_option`, and on the game server it is a `GameServerError` with the code `bad_room_call` and the room call (like `room.broadcast`) as its field. Bytes have their own keys.
- **Zaisma rooms carry them over the WebSocket today**, since Cloudflare doesn't yet let Workers take WebTransport or WebRTC data channels; the same `delivery: "latest_only"` moves to real datagrams once it does, with no change to your game. **On your own server, the fast lane carries them as datagrams already** (below). Anything else for `delivery` or `latestKey` throws in your code, naming what to give: the SDK's error has the code `bad_send_option`; the game server's is a `GameServerError` (`bad_room_call`) saying the same.
### The fast lane to your own server
`Zaisma.joinRoom({ serverUrl: "wss://play.example.com", transport: "webtransport" })` joins a room on your own server over WebTransport (HTTP/3 over UDP) instead of the WebSocket. The Node runner serves it with `--webtransport-port`, `--certificate-path` and `--certificate-key-path` (`startServer({ webtransportPort, certificatePath, certificateKeyPath })`, all three or none); any other server can speak it too. `transport` is `"websocket"` (the default) or `"webtransport"`, else the SDK refuses it with `bad_transport`; a `serverUrl` that isn't `wss://` or `https://`, and Zaisma's own rooms, use the WebSocket either way. If WebTransport isn't there, its session is refused, or it isn't up within 3 seconds (`FAST_LANE_CONNECT_TIMEOUT_MS`), the room uses the WebSocket for the rest of its life and logs one console warning; a fast lane that worked and then dropped is tried again first. `room.transport` says what the connection uses now.
The wire:
- **The session** is at `https://<server>/v1/rooms/<game>/<code>`: the `serverUrl`'s host and port, with `wss:` read as `https:`. The browser sends the page's `Origin`; check it as you do for the WebSocket. The certificate must be a real one for that name (browsers check it as for any HTTPS site).
- **One bidirectional stream**, opened by the client first, carries every frame the WebSocket carries, in order: each is `[4-byte big-endian payload length][1-byte kind: 0 text, 1 bytes][payload]`. Text is the same UTF-8: the JSON messages (`hello`, `welcome`, `probe`, `probe_answer`, ...) and `ping`/`pong`. Bytes are the same binary frames: from the room, `[1-byte sender ID length][sender ID][bytes]`; from the client, the bytes alone.
- **A datagram** is `[1-byte kind][payload]`, with the same payloads, and carries only `latest_only` sends, both ways, when it fits the session's `maxDatagramSize`; a bigger one goes on the stream. Take datagrams only from a player you let in.
- **Closing:** the session's close info carries the WebSocket's close codes and reasons (`closeCode` 4000 to 4004, as in [Close codes](#close-codes)).
A server of your own that isn't the Node runner (Rust, C++, a studio's engine) needs to: accept WebTransport sessions at that path and check `Origin`; read the hello from the stream and verify its pass against your game's keys at `https://rooms.zaisma.com/v1/pass-keys/<gameSlug>`; answer each `probe` the room protocol says to send, and every `ping` with `pong`; send the same frames on the stream, and `latest_only` ones as datagrams when they fit.
### Room error codes
A room answers a refusal with `{ type: "error", code, message }`, then closes the connection (`4001`, or `1013` for `busy`); a message it can't take gets the same `error` and the connection stays open. In the SDK they are `error.code` and the `error` event.
| Code | Meaning |
| --- | --- |
| `room_full` | The room has no space for another player. |
| `room_closed` | The room isn't taking new players (`room.setOpen(false)`). |
| `ended` | The match is over. |
| `too_big` | A message over 16 KB, or `joinData` over 4 KB. |
| `too_fast` | More messages than the room takes (30 a second, burst of 60). |
| `bad_message` | A message the room couldn't read or use. |
| `bad_pass` | The player pass wasn't accepted; the SDK gets a new one and tries once more. |
| `bad_player_token` | A game played off Zaisma sent a `playerToken` your own server didn't take (its `identifyPlayer` said no, or it takes no guests); the game gets the player a new one. |
| `no_hello` | The first message wasn't a hello with a player pass (or, to your own server, a `playerToken`). |
| `not_allowed` | Only the game server or the room's host can do that. |
| `game_unavailable` | The game can't be played right now. |
| `busy` | The room couldn't take the player right now; the SDK tries again soon. |
| `kept_out` | The player was removed for the rest of the match. |
| `refused` | The game server's `canJoin` turned the player away. |
| `room_not_running` | The room isn't running, like one with nobody playing to watch. |
| `rented_share_used` | This player is on a rented-server network, and the share of the game's hosting such traffic gets is used; everyone else plays on. Zaisma's page tells them to turn off their VPN or sign in. |
| `hosting_paused` | The game's hosting is paused this month, or Zaisma's free room time ran out; new rooms open again when it resets or its developer adds credit and a budget. |
| `account_needed` | The game needs a Zaisma account for multiplayer, and the player is a guest. |
| `game_not_open_to_player` | The account is younger than the game's minimum age. |
| `blocked_player_here` | Someone the player blocked is in the room; `quickJoin` tries other rooms first. |
| `other_version` | The room runs another version of the game (see Updates above). |
| `spectators_full` | The room takes no more spectators. |
| `spectator_cannot_send` | A spectator tried to send to the room. |
| `already_playing` | A player in the room tried to watch it too. |
| `bad_origin` | The connection didn't come from the game's own page. |
| `send_queue_full` | The SDK's own: more than 60 sends waited while it reconnected, so the oldest were dropped. |
| `chat_not_here` | A chat message reached a room whose server doesn't take chat (an older runner). |
| `chat_not_allowed` | `room.chat` from a guest, or a player whose chat is paused or removed (`room.canChat` is `false`). |
| `chat_empty` | `room.chat` with nothing but spaces. |
| `chat_too_long` | `room.chat` over 2000 characters. |
| `chat_too_fast` | More than 20 chat messages in 10 seconds from one player. |
| `voice_not_here` | A voice message reached a room whose server doesn't take voice (your own server: voice goes through a ticket, see Voice). |
| `microphone_refused` | The SDK's own: `room.voice.join` couldn't use the microphone (the player or the browser said no, or the game's `microphone_enabled` is off). |
| `voice_not_allowed` | `room.voice.join` from a guest or a spectator. |
| `voice_unavailable` | Voice couldn't start or connect: try again. |
| `voice_ticket_required` | `room.voice.join` in a room on your own server without a ticket from that server. |
| `voice_ticket_refused` | A voice ticket for another player, channel or game, expired, or signed with another secret. |
| `bad_region` | The SDK's own: a `region` that isn't a continent code (`"AF"`, `"AN"`, `"AS"`, `"EU"`, `"NA"`, `"OC"` or `"SA"`). |
| `bad_idle_timeout` | The SDK's own: an `idleTimeoutSec` that isn't from 30 to 86400. |
| `bad_transport` | The SDK's own: a `transport` that isn't `"websocket"` or `"webtransport"`. |
| `zaisma_rooms_not_used` | The SDK's own: the game doesn't use Zaisma rooms, so there are none to join or list. |
| `no_online_play_in_preview` | The SDK's own: the game is a preview of a version players don't have yet, which never plays online, so a test build never reaches live rooms. Test online play with `npx @zaisma/cli play-locally`, or publish the version and play it through a tester link (`add_tester_link`). A draft or private game's own page plays its live version online for its developer. |
### Close codes
| Code | Why | What the SDK does |
| --- | --- | --- |
| `4000` | The match ended (`room.end`, or Zaisma ending it) | Stops: `connectionStatus` `"closed"`, after the `ended` event with its `endReason` |
| `4001` | The room refused the player (an `error` with the code comes first, like `room_full`, `bad_origin` or `game_unavailable`), removed them (`room.kick`), or they joined from another tab | Stops: `connectionStatus` `"closed"` |
| `4002` | The seat held for a player who walked away ran out | `connectionStatus` `"closed"`; waits for the player to come back, then the `back` event with `isSeatHeld: false` |
| `4003` | The connection stopped answering probes or fell too far behind | Reconnects by itself, as a dropped player |
| `4004` | The match switched to a version published `"now"` | Reconnects by itself, or the page reloads the game at the new version (`isReloading`) |
| `1012` | The Node runner is restarting | Reconnects by itself, as a dropped player |
| `1013` | Zaisma rooms are busy (an `error` with `busy` comes first) | Reconnects by itself, waiting longer each try |
Any other close (a network drop) reconnects by itself too.
### Room events
Every event the game's room object has, and what its listener gets. Within v1, events and error codes only grow, so keep a `default` for ones you don't know.
| Event | Listener gets |
| --- | --- |
| `message` | `(message, fromPlayerId)` |
| `bytes` | `(bytes, fromPlayerId)` |
| `state` | `(state, changes)` |
| `players` | `(players)`, each `{ id, name, kind, awayReason }` |
| `connectionStatus` | `(connectionStatus)` |
| `settings` | `{ isListed, isOpen, friendJoinsEnabled, name, labels, spectatorCount }` |
| `ended` | `{ message, endReason }`: `game`, `no_players`, `hosting_paused`, `kept_room_deleted`, `game_unavailable` or `game_server_stopped` |
| `ending` | `{ endsAt }` |
| `endingCancelled` | `()`: the end `ending` announced is off, since the game's hosting started again; `room.endsAt` is `null` |
| `kicked` | `{ message, isKeptOut }` |
| `chat` | `{ fromPlayerId, text, hasSwearing, hasSlur, sentAt }`: another player's chat line (see Chat) |
| `move` | `{ roomCode, follow(), join(joinOptions) }` |
| `moved` | `{ roomCode, fromRoomCode }` |
| `idle` | `{ idleStatus, answerTimeoutSec }` |
| `away` | `{ awayReason, seatHoldDurationSec }` |
| `back` | `{ roomCode, isSeatHeld, rejoin() }` |
| `muted` | `(playerIds)` |
| `error` | `{ code, message }` |
| `versionUpdate` | `{ versionId, appliesAt, isReloading }` |
| `roomMessage` | `{ message, senderKind, fromRoomCode, sentAt }`: a room message for a room whose game server has no `onRoomMessage` (see Reaching live rooms) |
| `speaking` | `{ playerId, isSpeaking }`: a voice started or stopped speaking, this player's own included (see Voice) |
| `voiceSpeakers` | `{ playerIds }`: whose voices reach this player now changed |
The SDK and rooms say which messages they speak with `protocolVersionNumber` (1 today): the SDK sends it in its hello, and the welcome answers the room's. A room skips a message type it doesn't know, so a newer SDK still plays in an older room.
references/loading.md
CodeCopied
# A short first press
Open this when the game is more than a few MB, or when `performance_check` on a version says its first frame is slow. A player who presses Play and waits on a black screen leaves; one who sees something move in a second or two stays.
## The rule
Draw a first frame soon, show a loading screen if the rest takes time, and load the rest as it's needed, not all before the first frame.
## By size
- **A one-file or small game (under about 5 MB).** Nothing to do: it loads at once. Keep images and audio compressed, and don't load a big font or library the game doesn't use.
- **A mid-size game (5 to 100 MB).** Load what the first screen needs, show the menu, and load the levels, music and the rest while the player reads it. Show progress on anything that takes more than a second or two.
- **A big 3D build (100 MB and up, PC-grade).** Split it: a small first download that draws a menu or a loading screen within seconds, then the world in pieces, the first level first, the rest in the background or as the player reaches it. Every engine has a way: Unity's Addressables, Godot's PCK files loaded at runtime, glTF scenes streamed one by one in Three.js or Babylon.js.
## Making it smaller
`performance_check` (on `get_version`, `get_game` and in the upload command's output) says how the version started in headless Chrome: `loading_duration_sec` to the first frame, `start_download_size_bytes` before it, and notes with a fix for each. The ones that save the most:
- **Textures as KTX2** (Basis Universal): about a quarter of the size and of the graphics memory of PNG or JPEG for WebGL and WebGPU games.
- **Audio as Ogg Opus** or a compressed format instead of WAV.
- **Models with mesh compression** (meshopt or Draco).
- **A release build,** never a development or debug build: they're bigger and slower.
- **Compressed builds are fine.** Upload Unity's or Godot's `.br` and `.gz` files with `npx @zaisma/cli upload` which unpacks them.
## What not to do
- Don't hold the first frame for the whole game to download.
- Don't hide a long load behind a blank page: show progress, even a simple bar.
- Don't fetch files from other sites at start: the upload command downloads them into the game, so they come from Zaisma's servers.
references/multiplayer.md
CodeCopied
# Online play that holds up
Open this when the game has online play. It covers what Zaisma's rooms already do for a player whose connection is weak, and what the game itself has to add so it doesn't feel broken. The calls and options here are in `sdk.md` and `game-server.md`.
## Starting from the online core
For a game whose players move characters, push the same things at once, share things, send events or take turns, start from the piece `@zaisma/net` (`npx @zaisma/cli pieces add @zaisma/net`, reference in its `index.d.ts`) instead of writing the netcode: the game declares what each thing shares and how it moves in one step (a character on its own, a world of bodies together), and the piece does the rest, the same on the relay and with a game server: a player's own moves at once with the server's word eased in, everyone else smooth, what several players do to one body meeting in one place, hits judged by what the attacker saw, nothing sent while nothing changes, late joiners, drops, restarts, leavers and turns. What follows still applies to everything else the game sends.
For a game with third-person characters that run, jump and fight (battlegrounds, brawlers, hangouts, platformers), add `@zaisma/character` (`npx @zaisma/cli pieces add @zaisma/character`, reference in its `index.d.ts`) rather than writing a controller: it brings the online core, the default body and input, and gives snappy movement with a forgiving jump, a camera that turns freely, locks over the shoulder and zooms into first person, abilities that hit, and online play where a player's own moves answer at once. The level and the character go in one file both sides import (`defineLevel`, `defineCharacter`); with a game server, `zaisma-server/index.js` is `defineNetServer({ kinds: [fighters], onTick: (state, tickDurationSec, room) => fighters.judgeHits(state, room, tickDurationSec) })` with `fighters = characterKind(fighter)`. It's optional: a game may put its own characters on it, or use none of it.
For a game with physics (a shooter's arena, an outdoor map with vehicles, a building game, furniture carried together), add `@zaisma/physics` (`npx @zaisma/cli pieces add @zaisma/physics`, reference in its `index.d.ts`): it brings `@zaisma/net` and shares one physics world through the room with nothing to write for the sync: bodies, a big map's ground from a data file, joints, wheeled vehicles with seats, collision layers, queries, and characters that move by the game's own rules (`defineCharacterKind`). A player's own move answers at once, and a body at rest costs nothing. For party characters that grab, carry and throw, with one `feel` setting (`realistic`, `cartoony`, `floppy`), add `@zaisma/physics-party` on top. On the relay the host's game runs the world; with a game server, `zaisma-server/index.js` is `defineNetServer({ kinds: [physicsKind(world)] })` and the server runs it.
A shooter's character keeps what only its player needs to them (`audience: "own"`), says what happened in a step with `emit` (the server judges the hit by what the shooter saw, `takeEmitted` in its `onTick`), and holds its aim while inputs pause (`idleMode: "hold"`). To test it under a bad network in the game's own tests, `@zaisma/game-server/testing` runs its game server in memory with delay, loss and stalls.
## What the rooms already do
- **Reconnecting.** The SDK pings the room and reconnects by itself when the connection goes quiet, with no limit on tries. The game keeps the same room object, and `room.connectionStatus` is `"reconnecting"` meanwhile (`"connecting"`, `"open"`, `"reconnecting"` or `"closed"`).
- **Sends wait while it's down.** Reliable `room.send` calls made while the connection is down are kept in order and go once it's back, up to 60; past that the oldest is dropped and the room's `error` event says `send_queue_full` once.
- **A dropped player keeps their seat.** A player whose connection drops is away with reason `lost` for `reconnectTimeoutSec` (30 seconds unless the game server says otherwise, 0 to 300). They stay in `room.players` with `awayReason: "lost"`, nothing is sent to them, and their seat stays theirs. Back in time, the game server's `onBack(state, player, room)` runs; not back in time, `onLeave` with reason `lost`, and the room holds their seat for `seatHoldDurationSec`.
- **Slow connections are dropped early.** A player whose connection can't keep up (a probe unanswered for 8 seconds, or 2 MB sent since their last answer) is closed with code `4003` and becomes a dropped player, so one bad connection never stalls the match for everyone.
- **One clock and the ping.** `room.serverTimeMs()` is the room's clock on the game server and in every player's game. `room.pingDurationMs` is the player's round trip in milliseconds, measured by the room, so a player can only make it look worse, never better.
- **State sync.** With `stateSyncEnabled: true` on the game server, each player gets a full copy of their view as they join or reconnect, then only what changed. `stateView(state, viewer, room)` cuts what each one sees. A backed-up player gets nothing until they've caught up, then one full copy.
- **Restarts.** Zaisma restarts its rooms when Zaisma is updated: a real-time room saves its state every `stateSaveIntervalSec`, comes back from the save, and runs `onRestored(state, restoreInfo, room)`; every player comes back as a dropped player would.
## What the game must do
1. **Keep the game server in charge.** The game sends input ("move left", "fire at x, y"), never results ("I hit them", "I have 500 coins"). The game server checks every move against its own state and decides what happened. A game that trusts a player's results is a game anyone can cheat in.
2. **Show a dropped player as dropped.** Read `awayReason` from `room.players` (and the `players` event). Draw a `lost` player frozen, dimmed or marked "reconnecting", never running on in place. On the game server, skip `lost` players in `onTick` (`room.awayReason(playerId)`), or pause the match or skip their turn.
3. **Send the whole state to a player who comes back.** They missed what was sent meanwhile. Send it in `onBack`, and in `onJoin` when `joinInfo.isReturning`, not just what changed. State sync does this by itself.
4. **Show the player their own connection.** Listen for the room's `connectionStatus` event and show a small "Reconnecting…" while it's not `"open"`. Don't cover the game or end the match for a blip.
5. **Send less while it's down.** Movement and aim replace each other, so send them with `{ delivery: "latest_only", latestKey: "move" }`: only the newest waits, and a stale queue never builds. Keep reliable sends for things that must all arrive, like a purchase or a turn.
6. **Handle the end of the room.** Listen for `ended` and `kicked`, and give the player a way back to a menu or a new match.
## Turn-based games
A card game, a board game or a word game needs only the first four: the server checks each move, a dropped player's turn waits or is skipped by the game's own rule, a returning player gets the whole board, and the game shows the connection. Turn-based rooms sleep between moves and notice a silent drop within about 75 seconds, which is fine for turns.
## Real-time games
A shooter is the measure: if a shooter feels fair on a 150 ms connection with a little loss, every other real-time game will too.
- **Tick rate.** `ticksPerSec` on the game server runs `onTick(state, tickDurationSec, room)` that many times a second. 20 to 30 suits most action games; 60 only when the game truly needs it, since every tick is CPU on the game's hosting meter. Players' input reaches `onMessage` just before the next tick, in order.
- **Sending.** Send input when it changes, not every frame, and positions and aim with `{ delivery: "latest_only", latestKey }`. The SDK combines what the game sends at once into one message, keeps sends under the room's 30 a second by combining instead of failing, and skips a latest-only send that didn't change; leave both on unless the game server needs every send alone (`joinRoom({ sendCombiningEnabled: false, unchangedSkippingEnabled: false })`). Each message a room gets is billed.
- **Interpolation.** Draw other players from `room.smoothedState()` (or `room.smoothedState({ delayMs: 150 })`), the state a moment behind, blended between updates, so they move evenly however packets arrive. Blend angles that wrap around yourself.
- **Prediction.** Move the player's own character at once on their input, from the game's own copy of the rules, then correct it gently toward what the server says when its update arrives. Without prediction, every move waits a round trip and the game feels heavy. The SDK leaves prediction to the game.
- **Lag compensation.** For hits, the game server checks a shot against where targets were when the shooter saw them: keep a short history of positions (a few hundred milliseconds), and rewind by the shooter's `room.pingDurationMs(playerId)`. Cap the rewind (about 200 ms), since a slower connection should never be an advantage.
- **Times on one clock.** Send times as `room.serverTimeMs()` values, like `{ startsAtMs: room.serverTimeMs() + 3000 }` for a countdown, so they mean the same moment for every player.
- **Test it on a bad connection.** Run `npx @zaisma/cli play-locally`, add a second player, and give one a weak connection through the bench's API (`PUT /bench/api/open-players/<player_number>/conditions` with `{ added_ping_duration_ms: 150, maximum_bytes_per_sec: 500000, packet_loss_pct: 2, device_speed_pct: 25 }`), real for the game server too, then drop them for a few seconds (`POST .../drops` with `{ drop_duration_sec: 5 }`): the other player should see them freeze, then catch up, and they should see "Reconnecting…", then the whole match back. `POST /bench/api/restarts` with `{ restart_kind: "copy" }` starts the game server's copy again as Zaisma's rooms can at any time: the match should carry on from the room's state, with nothing it needs kept in the game server's own variables.
references/naming.md
CodeCopied
<!-- Made by scripts/build-skill.mjs: never edit it by hand. -->
# Naming
How names, values, inputs, examples, errors and next steps work everywhere an AI or a developer reads or writes Zaisma: the developer API, the developer and admin MCPs, the SDK, the game server API, the docs and examples that show them, and Zaisma's own code (database columns, types, functions and variables). It's the working half of "Nothing for an AI to guess" in `docs/DECISIONS.md`. The inside uses the same names as the outside, so nothing needs translating between them.
Why: an AI reading `files: 12`, `dt` or `created_at: 1792012345678` has to stop and work out what it means, and sometimes gets it wrong. Every guess costs tokens and some cost a wrong call. A name that says what it holds, what kind of value and in what unit lets the AI predict the right value and the right next call straight away.
The API, MCPs, SDK, game server and Zaisma's own code all use these names, inside and out, and a test keeps it that way: everything new follows this guide. The messages between the SDK and rooms do too: `type` and `data`, not `t` and `d` (rooms are billed per message, never by its size). Examples in this guide show the pattern; the glossary at the end lists the names that exist.
## The shape of a name
A name has up to three parts: **what it's about**, **what kind of value**, **in what unit**. `play` + `duration` + `min` is `play_duration_min`; `file` + `count` is `file_count`. The middle part tells the AI the kind of value before it reads the value.
| Kind of value | Name | Value | Example |
| --- | --- | --- | --- |
| Point in time | `<event>_at` | ISO 8601 string in UTC | `published_at: "2026-10-14T17:00:00Z"` |
| Calendar day | `<what>_date`, or `date` | `"YYYY-MM-DD"`, UTC | `date: "2026-10-14"` |
| Length of time | `<what>_duration_<unit>`, or a duration word below in place of `duration` | number | `play_duration_min`, `idle_timeout_sec` |
| Count | `<thing>_count` | integer | `file_count`, `player_count` |
| Place in a list | `<what>_index` | integer from 0 | `channel_index: 2` |
| Step on a fixed scale | `<what>_level`, its values listed in the schema | integer | `quality_level: 2` |
| Rate | `<things>_per_<unit>` | number | `ticks_per_sec`, `posts_per_day` |
| Size | `size_bytes`, `<what>_size_bytes` | integer | `size_bytes: 52000` |
| On-screen length | `width_px`, `height_px`, `<what>_px` | number | `width_px: 1920` |
| Angle | `<what>_deg`, or `<what>_rad` in a game's 3D maths | number | `rotation_deg: 35`, `mouse_look_rad_per_px` |
| Point or direction in space | `<what>_<unit>`, holding `x`, `y` and `z` as every engine names them; a part on its own is `<what>_x_<unit>` | `{ x, y }` or `{ x, y, z }` | `look_rad: { x, y }`, `look_x_rad`; a push of length 1 at most, like a stick's, needs no unit: `move: { x, y }` |
| Rotation in space | `rotation`, holding `x`, `y`, `z` and `w` as every engine names a quaternion's parts; a turn written by hand is `<what>_deg: { x, y, z }` | `{ x, y, z, w }` | `rotation: { x: 0, y: 0.38, z: 0, w: 0.92 }`, `rotation_deg: { x: 0, y: 45, z: 0 }` |
| Share | `<what>_pct` | number, 0 to 100 | `returned_pct: 42` |
| Yes or no | `is_`, `has_` or `can_` first; `<setting>_enabled` for a setting someone switches; a verb for an input that asks for an action | boolean | `is_live`, `cloud_saves_enabled`, `reopen: true` |
| Choice | `<what>_status`, `_kind` or `_mode`, or the setting's own name | one of a fixed list | `scan_status: "held"`, `visibility: "listed"` |
| ID | `id` for the object's own; `<kind>_id` for one that points at another | `<kind>_<random>` | `id: "version_8f3k2m…"`, `version_id: "version_8f3k2m…"` |
| List | plural noun; a list of IDs is `<kind>_ids` | array | `files`, `image_ids` |
| Text in a format | `<what>_url`, `_base64`, `_markdown` | string | `preview_url`, `text_markdown`, `images_base64` |
| Plain text | the thing's name, no suffix | string | `title`, `description` |
### Units
The only unit suffixes:
| Suffix | Unit |
| --- | --- |
| `_ms` | milliseconds, only where under a second matters |
| `_sec` | seconds |
| `_min` | minutes |
| `_hours` | hours |
| `_days` | days |
| `_years` | years, for ages (`minimum_player_age_years`) |
| `_bytes` | bytes |
| `_px` | CSS pixels |
| `_m` | metres, for lengths and distances in a game's world (one three.js unit is a metre) |
| `_kg` | kilograms, for how heavy a thing in a game's world is, and the weight a character carries (`mass_kg`, `carry_strength_kg`) |
| `_deg` | degrees |
| `_rad` | radians, for angles a game's 3D maths uses as they are (three.js turns in radians) |
| `_lux` | lux, for how strongly a light shines, as three.js's lights take it |
| `_newtons` | newtons, for a force in a game's world (a car's engine and brakes, as the physics engine takes them) |
| `_pct` | percent, 0 to 100 (never 0 to 1) |
| `_cents` | US cents, a number that may have a fraction (`review_cost_cents`); Stripe works in cents too |
| `_minor_units` | the smallest unit of the currency in the `currency_code` beside it (cents, pence; yen are whole), as Stripe counts amounts (`price_minor_units`) |
Rates reuse them with `per` and the singular: `_per_sec`, `_per_min`, `_per_hour`, `_per_day`. Pick the unit people think in for that quantity (minutes played, player hours a month), then use that same unit for it everywhere.
The list stays short on purpose: each new suffix makes every suffix worth less. Add one only when a real field can't be said with these, and add it here in the same change.
### Duration words
A length of time says so in its name. `duration` is the default; four words say more when they fit:
| Word | Means | Example |
| --- | --- | --- |
| `duration` | how long something lasts | `play_duration_min`, `seat_hold_duration_sec` |
| `timeout` | how long before something gives up or steps in | `idle_timeout_sec` |
| `interval` | time between repeats | `ping_interval_sec` |
| `delay` | wait before something starts | `publish_delay_min` |
| `cooldown` | wait before it can happen again | `vote_cooldown_sec` |
## Rules
1. **Whole words.** The only short forms are the units above, `id`/`ids`, `url` and `sha256`, `x`, `y` and `z` for a point's or direction's parts, plus `i` for a loop index in code. Not `dt`, `dx`, `msg`, `opts`, `pos`, `t`, `num`, `max`, `min`, `cfg`, `res`, `err`, `e`.
2. **Minimum and maximum are spelled out**, as the first word: `minimum_player_count`, `maximum_player_count`. `_min` at the end always means minutes.
3. **Vague nouns get a subject.** `data`, `info`, `value`, `result` and `context` never stand alone: `join_data`, `failure_context`.
4. **One type and one unit per field.** No "a number or false", no "a string or a number". A setting with modes is a choice plus a separate number: `idle_check: "server" | "client" | "off"` and `idle_timeout_sec: 600`, not `idleAfter: 600 | false | "client"`.
5. **A field reads right on its own.** If its short name means something else elsewhere in the glossary, use the full name. `code` is an error's code, so a room's is `room_code`; `players` is a list of players, so a number of them is `player_count`. On an object, `id` and `kind` are that object's own; anything else about it says what it is (`scan_status`, `review_status`, `page_url`, `image_url`).
6. **One name per concept, everywhere.** The glossary below is the list. Check it before naming anything; a new concept goes into it in the same change.
7. **Same words in each surface's style.** snake_case in the API and MCP (`play_duration_min`), camelCase in the SDK and game server (`playDurationMin`). The one exception: a webhook event reaches the game server as the API's own JSON, snake_case, so one event reads the same everywhere. Choice values and error codes are lowercase snake_case everywhere (`when_approved`, `keyboard_mouse`, `hosting_paused`); a word that's hyphenated in plain English keeps its hyphen (`co-op`).
8. **Keys are always there.** An answer has the same keys every time. `null` means "not set" or "none" and nothing else. In an update, leaving a key out keeps it and `null` clears it.
9. **A plural is always a list.** A number of things is never a bare plural, and a list names what's in it when that isn't obvious: `image_ids` holds IDs, `images` holds image objects, `images_base64` holds encoded images.
10. **Times go in and out as ISO 8601.** Out: UTC with `Z`. In: ISO 8601 with `Z` or an offset, nothing else (no epoch numbers).
11. **Lists that page** take `cursor` and answer `next_cursor`: an opaque string, `null` on the last page. Never a timestamp standing in for a cursor.
Good and not:
| Good | Not | Why |
| --- | --- | --- |
| `file_count: 12` | `files: 12` | `files` is a list elsewhere |
| `created_at: "2026-10-14T09:30:00Z"` | `created_at: 1792012345678` | An AI can't read a date from a number without working it out |
| `idle_timeout_sec: 300` | `idle: 300` | Seconds? Minutes? And what about idle? |
| `tickDurationSec` | `dt` | Short forms hide both the meaning and the unit |
| `maximum_player_count: 8` | `max: 8` | `max` of what, and `min` clashes with minutes |
| `returned_pct: 42` | `percent: 42` | Percent of what |
| `vote_count` and `affected_developer_count` | `count`, meaning one or the other by kind | One name, one meaning |
## Zaisma's own code
The same rules hold inside, with these on top. `test/node/naming.test.ts` checks identifiers, type fields and the database columns the migrations make, in the TypeScript, the JavaScript the packages ship (the SDK, the CLI, the Node runner) and the SDK's types.
- **Same words, two styles.** Database rows and API data are snake_case (`review_status`, `size_bytes`); variables, functions and types are camelCase or PascalCase (`reviewStatus`, `sizeBytes`). Never mix them in one shape: a stored JSON object is snake_case all the way down.
- **Columns take the API's names**, so the API passes data through instead of renaming it: `games.review_status`, `versions.patch_notes`, `game_images.width_px`. When the API shows something differently (an ISO time, a list made from text), only the value's form changes, never its name.
- **Stored times are `<event>_at_ms`**: epoch milliseconds, in columns and in variables (`createdAtMs`). `_at` always means an ISO string. `iso()` (`packages/core/src/time.ts`) is the only conversion between them.
- **Yes/no columns are named like booleans** (`cloud_saves_enabled`, `is_listed`), even though D1 stores them as 0 or 1. Every other number column ends in `_count`, a unit, `_ms`, `_per_<unit>`, `_index` or `_level`.
- **Whole words everywhere**, callback parameters included: `games.map((game) => …)`, `catch (error)`, `(first, second) => …` in a sort. `i` is the one short name, for a loop index.
- **Names the platform sets keep its spelling**: Worker bindings and secrets in `Env` (`DB`, `GAMES`), `env` and `ctx` in Worker handlers, and Web and Cloudflare API fields (`httpMetadata`, `etag`). Our own variables holding them still get whole words (`response`, not `res`).
- **No old names are left.** `test/naming-baseline.json` is empty, and the check fails on any name that breaks these rules. Should a name ever have to wait, it goes in that list (`npm run naming:baseline` writes it), and the check then fails on any new one and on any listed one that's gone, so the list only shrinks.
- **A standard's shapes keep its names** (Exceptions below): declare the shape with a name, like `TurnstileAnswer` or `PassClaims`, and list its standard fields in `STANDARD_FIELDS_BY_SHAPE` in `test/naming-source.ts`. Only those fields of that shape are let through; anything of ours in it still follows the rules.
## IDs
Every ID Zaisma makes says its kind in its value: `<kind>_<random>`, the kind in whole words (`play_ticket_…` for a kind of two words; the random part never has an underscore). An object's own ID is `id`, because the value already says what it is; an ID that points at another object is `<kind>_id` (`{ "id": "post_4k…", "topic_id": "topic_9x…" }`). An AI always knows what it's holding, and passing one where another kind belongs gets a clear error: `wrong_id_kind`, "That's an image ID; version_id takes a version ID.", with a fix naming the call that lists the right ones. Schemas give every ID its kind as a pattern (`^version_[a-z0-9]+$`), and `test/site/naming.test.ts` checks that they do.
| Kind | Example |
| --- | --- |
| `game` | `game_…` |
| `version` | `version_…` |
| `image` | `image_…` |
| `clip` (a game's short silent loop its shared links play) | `clip_…` |
| `shader` | `shader_…` |
| `tester` | `tester_…` |
| `topic` (known issues too) | `topic_…` |
| `post` | `post_…` |
| `report` | `report_…` |
| `media` | `media_…` |
| `precedent` | `precedent_…` |
| `player` | `player_…` |
| `owner` | `owner_…` |
| `save_copy` | `save_copy_…` |
| `play_ticket` | `play_ticket_…` |
| `room_key` | `room_key_…` |
| `sign_in_app` | `sign_in_app_…` |
| `chat_group` | `chat_group_…` |
| `player_tag` | `player_tag_…` |
| `webhook` | `webhook_…` |
| `webhook_event` | `webhook_event_…` |
| `chat_review` | `chat_review_…` |
| `mcp_client` (an AI app that connects to the MCP by signing in; one that uses a metadata document is named by its URL instead) | `mcp_client_…` |
| `database_restore` (a restore of a game's database to a time, or the undo of one) | `database_restore_…` |
| `kept_room_restore` (a restore of a kept room's world to a time, or the undo of one) | `kept_room_restore_…` |
| `kept_room_restore_batch` (every kept room of a game going back to a time, or the undo of that) | `kept_room_restore_batch_…` |
| `whats_on_entry` (an event, news or a pick a person added to What's on at Zaisma) | `whats_on_entry_…` |
| `announcement` (short news Zaisma posts for players, shown on zaisma.com's home) | `announcement_…` |
| `top_up` (credit a developer bought on Stripe's page) | `top_up_…` |
| `credit_entry` (any other change to a developer's credit: a game's hosting charge for a day, a refund, what Zaisma wrote off) | `credit_entry_…` |
| `purchase` (a player's purchase or grant of an item in a game) | `purchase_…` |
| `spending_request` (a raise in spending an AI asked for, which only the developer approves on zaisma.com) | `spending_request_…` |
| `game_deletion_request` (a deletion of a game a key, an AI app or the dashboard asked for, which only the developer approves on zaisma.com) | `game_deletion_request_…` |
| `pending_refund` (a deleted account's refund Stripe hasn't taken yet; never shown outside Zaisma) | `pending_refund_…` |
| `scheduled_room_message` (a send to every room a game scheduled for later) | `scheduled_room_message_…` |
| `ban_match` (another account that paid with a card banned with an account, for a person at Zaisma to decide; only in the admin MCP) | `ban_match_…` |
| `ncmec_report` (a report to NCMEC's CyberTipline; never shown outside Zaisma) | `ncmec_report_…` |
| `admin_change` (a change the admin's AI asked for, waiting for the admin's passkey tap; never shown outside Zaisma) | `admin_change_…` |
| `inbox_notice` (a notice in an account's inbox: from Zaisma, or a game the account follows) | `inbox_notice_…` |
| `room_invite` (a friend's invite into the room they're in, waiting in the other's bell for a day) | `room_invite_…` |
| `game_invite` (a developer's invite of a player's account to their private or draft game) | `game_invite_…` |
| `piece` (a piece on the developer marketplace; calls take its name, `piece_name`) | `piece_…` |
| `piece_version` (one version of a piece, by its number in calls: `piece_version`, like `1.2.0`) | `piece_version_…` |
| `piece_image` (a cover or gallery picture of a piece's listing; `image_id` in its calls) | `piece_image_…` |
| `feedback` (what a player told a game's developer from inside the game; `feedback_id` in its calls) | `feedback_…` |
`ID_KINDS` (`packages/core/src/ids.ts`) is this list, and a test keeps the two in step; a new kind is added to both in the same change. Accounts' and guests' player IDs are both `player_…`, in their passes and everywhere the SDK and game server show them; an account's never changes, and Zaisma's own account ID (the sign-in's) never leaves Zaisma. The developer API and MCP still name a game by its `slug`, the link name developers know. Not IDs, and kept as they are: a `slug`, a `room_code` (six letters players type), API keys (`zsk_…`, a format secret scanners know), connected apps' access and refresh tokens (`zat_…`, `zrt_…`), webhook signing secrets (`whsec_…`, Standard Webhooks' form) and file hashes (`sha256`).
## Inputs
- **Fixed lists, not free text.** A field with known values is an enum in the schema, and its description says what each value means.
- **Templates, not free-form objects.** Every object has its properties, which are required and `additionalProperties: false`. No bare `{ "type": "object" }`.
- **Every ID says where it comes from**: "A version_id from get_game or upload_files".
- **Limits live in the schema** (`maxLength`, `minimum`, `maximum`, `maxItems`, `pattern`), not only in prose.
### Examples
The bar: a model that has never seen Zaisma gets the call right the first time from the schema alone. Where we aren't confident it would, add examples until it would, as many as the call needs:
- **None** for simple lookups like `get_game({ slug })`.
- **One good example** for a typical write.
- **Several good and bad** for big or flexible tools, like `update_game`'s players, `upload_files`, `post_topic` and `search_forum`.
Good examples go in the input schema's `examples`, with realistic values (real-looking slugs, prefixed IDs, ISO times). Bad examples go at the end of the tool's description, one line each, with the reason:
```
Not: { "at": 1792012345678 } (scheduled_publish_at takes an ISO time like "2026-11-01T17:00:00Z")
```
A mistake that keeps showing up in MCP errors becomes a bad example.
## Outputs
- **Every MCP tool has an output schema** (`apps/site/src/schemas.ts`), with each field described once there where its name can't say it all. Not every AI app shows output schemas to the model, so the names carry the meaning, and the tool's description adds only what a reader of the answer must know that names can't carry (like what counts as a play).
- **Compact JSON.** Answers aren't indented: indenting costs tokens and tells the AI nothing.
- **The same shape every time** (rule 8).
- **Brief by default** for anything that can be long, with a way to ask for more.
## Errors
Every error, in the API and the MCP, has the same shape:
```json
{ "error": { "code": "bad_time", "message": "scheduled_publish_at is in the past.", "field": "scheduled_publish_at", "fix": "Give an ISO time from 5 minutes to 90 days ahead, like \"2026-11-01T17:00:00Z\".", "message_for_people": "That time is outside the range this takes. Pick another.", "retry_after_sec": null, "help_url": "https://zaisma.com/developers/errors/bad_time" } }
```
- `code`: stable, lowercase snake_case, one problem per code, never reused for another.
- `message`: what happened, in one sentence.
- `field`: the input at fault, or `null`.
- `fix`: what to do about it, naming the call or value when there is one.
- `message_for_people`: what happened and what to do, for a page to show; never names a call or field. Every code has one (`messageForPeople` in `ERROR_CODES`), and a throw gives its own only for specifics like a count or a name.
- `retry_after_sec`: how long to wait when waiting helps (like `slow_down`), else `null`.
- `help_url`: the code's page at `https://zaisma.com/developers/errors/<code>`, with what it means and the general fix (`fix` in `ERROR_CODES`); `null` for the admin MCP's own codes, which have no page.
A page shows only `message_for_people`; `message` and `fix` are for the caller. Review reasons, findings and alerts carry `message_for_people` beside their `fix` the same way.
In the MCP the same object is the tool result's `structuredContent`, with `isError: true` and its message, fix and code as its text (`<message> <fix> (<code>)`), and each tool's listed output schema is its answer or the error (`anyOf`), because MCP clients check an error's `structuredContent` against it too. Every code is in `ERROR_CODES` (`packages/core/src/errors.ts`) and listed in `docs/DEVELOPER-API.md`, which a test keeps in step.
## Next steps
Every call that changes something answers with `next_steps`: the calls that usually follow, ready to make.
```json
"next_steps": [
{ "tool": "get_version", "arguments": { "slug": "sky-hopper", "version_id": "version_8f3k2m" }, "after_sec": 30, "reason": "The scan usually takes under a minute." }
]
```
- `tool` is the MCP tool's name; `arguments` are what to send, filled in.
- `after_sec`: how long to wait first, or `null` for straight away.
- `reason`: why this is the next step, in one short sentence.
- `next_steps` is `[]` when nothing usually follows.
## Exceptions
Deliberate, and only these:
- **Standard formats keep their own names**: HTTP headers, JSON-RPC and MCP fields (`inputSchema`, `isError`, `structuredContent`) and JSON Schema keywords (`maxLength`). So do the shapes of standards and outside services Zaisma reads: JWT claims (`exp`, `nbf`, `iat`), OAuth and OpenID Connect at `/oauth/` and `/.well-known/` (`client_id`, `redirect_uri`, `id_token`, `expires_in`, `auth_time`, `invalid_grant`), WebAuthn's client and authenticator data (`crossOrigin`, `flags`), R2's ranges (`offset`, `length`, `suffix`), and what Cloudflare Turnstile (`success`) and VirusTotal answer.
- **A save's IndexedDB databases** keep IndexedDB's own names (`keyPath`, `autoIncrement`, `unique`, `multiEntry`, `version`), and their records keep the `$z` tags (`{"$z": [kind, …]}`) inside `indexeddb_databases`: they're the browser's and the game domain script's (`packages/sdk/saves.js`), not ours.
- **API keys** keep `zsk_`, and webhook signing secrets Standard Webhooks' `whsec_`; the headers webhooks are sent with (`webhook-id`, `webhook-timestamp`, `webhook-signature`) are Standard Webhooks' own.
## Glossary
One name per concept. The API and MCP column is snake_case; the SDK and game server column is camelCase. ID rows give the name for pointing at one; on the object itself it's `id`.
| Concept | API and MCP | SDK and game server |
| --- | --- | --- |
| A game's link name, as in zaisma.com/g/<slug> | `slug`; `new_slug` changes a private draft's (`can_change_slug`, else `slug_locked`) | `slug` |
| A game's genres: up to 3 from one fixed list, which players filter Browse by | `genres` (a list of `action`, `adventure`, `role_playing`, `shooter`, `strategy`, `simulation`, `racing`, `sports`, `fighting`, `platformer`, `puzzle`, `horror`, `survival`, `sandbox`, `card_and_board`, `party`, `rhythm`, `visual_novel`); refused with `bad_genres`. Inside: `games.genres` (comma-separated), `GENRES`, `GENRE_LABELS`, `MAXIMUM_GENRE_COUNT` | |
| A version of a game, and its short number in the game (Build 14), the same for its developer and its testers | `version_id`; `build_name` (`Build 14`), `current_build_name` and `next_build_name` on a tester link; columns `versions.build_number` (from 1), `games.build_count` | |
| An error code's page, with what it means and the general fix | `help_url` | |
| The Zaisma skill: the workflow and its references, for any AI, installed by the upload command | `zaisma skill` (the command); MCP resources `zaisma://skill`, `zaisma://sdk`, `zaisma://naming`, `zaisma://errors`, `zaisma://game-server`, `zaisma://developer-api`, `zaisma://multiplayer`, `zaisma://loading`, `zaisma://phones`, `zaisma://saves`; MCP prompts `make_game`, `publish_game`, `fix_problem` | |
| How many accounts have a game in their favorites (Your games) now, never who | `favorite_count` | |
| A cover or gallery picture | `image_id` | |
| A game's clip: up to 6 seconds of the game, silent and looping, that its shared links unfold into where an app plays one, and its still (the clip's first frame) everywhere else | `clip` on a game: `id`, `review_status`, `review_reason`, `width_px`, `height_px`, `duration_ms`, `size_bytes`, `clip_url`, `still_url`, `created_at`; inputs `clip_base64`, `still_base64`; tools `add_clip`, `remove_clip`; the upload command's `clip`; the bench's Record a clip and `POST /bench/api/clips` (`clip_file`, `still_file`); errors `not_a_clip`, `clip_has_sound`, `clip_too_long`, `clip_too_big`, `bad_clip_dimensions`, `bad_clip_still`, `clip_refused`, `no_clip`, `no_canvas`. Inside: `game_clips`, `CLIP_LIMITS` | `CLIP_LIMITS` |
| A game's world behind Zaisma's glass, for one screen, and what it shows | `background`: `screen`, `source` (`zaisma`, `image`, `shader`, and on phone `wide`), `image_id`, `shader_id`, `still_url`; pictures are images of `kind` `background` and `phone_background` | |
| Which screen a background is for | `screen`: `wide` (desktops and tablets), `phone` (composed for a tall screen); errors `bad_screen`, `bad_background_source`, `background_not_ready` | |
| A small program that paints a background live | `shader_id`; a shader's `image` pass and `buffers`, `quality_checks`, `has_quality_levels`, `flash_count`, `still_url`, `frame_urls`, each pass's `source_url`, `buffer_count`, `texture_count`, `texture_image_ids`. Its source keeps Shadertoy's names on purpose (`mainImage`, `fragColor`, `fragCoord`, `iResolution`, `iTime`, `iTimeDelta`, `iFrame`, `iChannel0` to `iChannel3`, `iChannelResolution`), the form AI already writes, so nothing is left to guess; Zaisma's own inputs follow them (`iQuality`, `iGlassPanes`, `iGlassPaneCount`) | `SHADER_LIMITS`, `ShaderManifest` |
| A buffer of a shader: a pass drawn to a picture kept between frames | `buffer_name` (`a` to `d`), `source`, `channels`; errors `bad_buffers`, `too_many_buffers` | |
| What a shader pass's iChannel reads | `channels`, each `{ channel_index, input_kind, buffer_name, image_id, filter, wrap }`: `input_kind` `buffer` or `texture`, `filter` `linear` or `nearest`, `wrap` `clamp` or `repeat`; error `bad_shader_channel` | `ShaderChannel` |
| A picture's tiny copy that pages show blurred until it arrives | `placeholder_data_url` on an image and a shader; `ShownPicture` (`imageUrl`, `widthPx`, `heightPx`, `placeholderDataUrl`) in Zaisma's pages; `PICTURE_PLACEHOLDER` | `ShownPicture`, `PICTURE_PLACEHOLDER` |
| A picture a shader reads | an image of `kind` `shader_texture`; errors `shader_texture_too_big`, `too_many_shader_textures`, `shader_texture_in_use` | |
| How much a shader draws on a device, and what the check measured at each | `quality_level` (`0` phones and slow devices, `1`, `2` desktops; `iQuality` in the shader), `quality_checks`, each `{ quality_level, check_frame_ms, maximum_check_frame_ms }` | `qualityLevel` |
| A shader drawn before it's sent | `shader_check`: `compile_error`, `quality_checks`, `flash_count`, `is_glass_smoked`, `glass_tint_pct`, `notes` (each `{ code, message, fix }`, codes `shimmers_when_small`, `forces_thick_glass`), `sheet_url`, `sheet_expires_at`; `remaining_shader_check_count`; errors `daily_shader_checks_used`, `shader_check_unavailable`. The upload command's `check` on a shader's folder answers it with `renderer_kind` (`local_chrome`, `zaisma`), `sheet_file` and `texture_images` | `ShaderCheckAnswer` |
| A shader as a folder, as the upload command reads and sends it | `image.glsl`, `buffer-a.glsl` to `buffer-d.glsl`, `channels.json` (passes `image`, `buffer-a` to `buffer-d`, each a list of channels with `texture_file`, a texture's file in the folder, in place of `image_id`); `shader --json` answers `texture_images` (each `{ texture_file, image_id, added_image }`) and `added_shader`; `help --json`'s `shader_folder`; errors `no_image_pass`, `unknown_shader_file`, `bad_channels_file`, `shader_texture_not_approved`, `no_chrome`, `local_chrome_failed` | `shaderCheckPageExpressions`, `shaderDraftAnswer` (`packages/cli/shader-check.mjs`) |
| The color Zaisma tints its glass with over a game's background | `glass_tint_color` (`#RRGGBB`), error `bad_color` | |
| A tester link | `tester_id` | |
| A forum topic, a post in it | `topic_id`, `post_id` | |
| A game named on something else, like a forum topic | `game_slug` | |
| The known issue a message to Zaisma is about | `known_issue_topic_id` | |
| Where a forum topic stands | `topic_status`: `new`, `investigating`, `known`, `planned`, `fixing`, `released`, `fixed`, `wont`, `answered` | |
| Where a topic belongs | `category` (like `rooms`), in a `section` (like `multiplayer`) | |
| Words to search for | `search_text` | |
| A post's words, and the images sent with it | `text_markdown`, `images_base64`; a post's images are `media`, each with an `image_url` | |
| Who wrote a post | `author`: `{ name, kind, is_you }`, `kind` one of `developer`, `ai`, `zaisma`; `author_kind` when sending | |
| What an AI attaches for whoever fixes a problem | `debug_context`: `{ call, error_code, error_message, request_json, notes }` | |
| The check a public post passes before others see it | `check_status`: `pending`, `passed`, `held` | |
| Votes on a topic, and the developers a known issue affects | `vote_count`, `affected_developer_count` | |
| What a developer thinks of a post, anonymously | `rating`: `like` or `dislike`; `like_count`, `dislike_count`, `your_rating` | |
| A post saved to read again, private to the account | `bookmark`; `is_bookmarked`, `bookmarked_post_ids` | |
| Taking back a vote, a rating, a bookmark or a follow | `undo: true` in the MCP; `DELETE` in the API | |
| Posts an account can still make today | `remaining_post_count` | |
| A room players join by typing it | `room_code` | `roomCode`; the game server's own room's, `room.roomCode` |
| A player, and the players a call is for or leaves out | `player_id` | `playerId`; `playerIds`, `exceptPlayerId` |
| Whether a player is signed in | a player's `kind`: `account`, `guest` (also the player pass's `kind` claim), and on a developer's own server `outside_zaisma` | `kind`; `playerKind` where it isn't on a player |
| What anyone sees of an account | `player`: `{ id, name, username, display_name, bio, link_urls, profile_url, is_profile_private, published_games, played_games, playing_now }`, its public profile | `PlayerProfile`, `Zaisma.player.getProfile(playerId)` (`displayName`, `linkUrls`, `profileUrl`, `isProfilePrivate`, `publishedGames`, `playedGames`, `playingNow`) |
| What a player writes on their profile, the check it passes, and who gets past its header | `display_name`, `bio`, `link_urls`; `profile_check_status`: `pending`, `passed`, `held` (in Zaisma's own code); the social setting `who_sees_profile`: `friends`, `anyone` | |
| Roughly when a player last played a game (a profile never shows a time) | `played_period`: `today`, `this_week`, `this_month`, `earlier` | `playedPeriod` |
| An account's unique name, as in @username (3 to 20 letters, numbers and underscores, unique ignoring case; it can change, the player ID can't), and the name games show for a player (an account's username; a guest's made-up one) | `username`; `name` | `username`; `name` |
| An account Zaisma banned, and how far | `banned_at`, `ban_scope`: `developer`, `whole_account` (`GET /access`, the admin MCP's `ban_account`); error `account_banned`; Zaisma's own code: `accounts.banned_at_ms`, `accounts.ban_scope`, `accounts.ban_reason`, `accounts.ban_content_rule`, `BAN_SCOPES` | |
| What a ban carries to new accounts | `banned_mark_count`; errors `stripe_account_banned`, `email_banned`; finding `matches_banned_account_files`; a ban match (`ban_match_id`, `decision`: `banned`, `not_the_same_person`); Zaisma's own code: `banned_marks` (`mark_kind`: `card`, `stripe_account`, `email`; `mark_sha256`, `banned_account_id`), `owner_cards` (`card_fingerprint_sha256`, `first_paid_at_ms`), `ban_matches`, `BAN_MARK_KINDS`, `BAN_MATCH_DECISIONS` | |
| What an account has earned, and what each power needs | `standing` (`GET /access`): `is_established_developer`, `outside_links_enabled`, `search_engines_enabled`, `returning_player_count`, `minimum_returning_player_count`, `account_age_days`, `minimum_account_age_days`, `has_card_or_stripe_account`, `last_ruling_at`, `ruling_wait_ends_at`; the admin MCP's `set_zaisma_account` (`is_zaisma_account`); Zaisma's own code: `game_returning_players` (`first_counted_date`, `last_counted_date`, `counted_day_count`), `accounts.counted_play_day_count`, `accounts.last_counted_play_date`, `owners.last_ruling_at_ms`, `owners.returning_player_count`, `owners.is_established`, `owners.standing_checked_at_ms`, `owners.is_zaisma_account`, `STANDING_LIMITS`, `standingOf`, `recordReturningPlay`, `noteRuling`, `checkStanding`, `isStrangerChatWaiting`, `SEARCH_ENGINES_ENABLED_SQL` | |
| A link that opens once the developer is established | `who_can_open` `waiting_for_standing` | |
| Who reads what an account types, whether it reads others' chat, and the opaque group of its age band (never an age) | `who_reads_my_chat`: `friends`, `my_age_band`, `everyone` (the social setting, outside the presets, `defaultWhoReadsMyChat`), `chat_reading_enabled` (Zaisma's own code: `accounts.who_reads_my_chat`, `accounts.chat_reading_enabled`, `PRESET_SOCIAL_SETTINGS`) | player pass claims `who_reads_my_chat` (`WhoReadsMyChat`, or `nobody` while stopped), `chat_reading_enabled`, `chat_group_id` (a `chat_group_…` ID, different in every game), v1's `who_can_chat` (`WhoCanChat`: `nobody`, `friends`, `anyone`) as a stricter stand-in; checked with `canChat(first, second)`, first the sender and second the reader; inside, `ChatReach` (`nobody`, `friends`, `my_age_band`, `everyone`), `chatReachOf`, `isWithinChatReach`, `PlayerChatSettings` (`sending`, `reading`, `chatGroupId`, `networkSeal`) |
| A chat message: a line a player typed, sent with room.chat through the room to the players who may read it, after the game server's onChat and Zaisma's chat filter | `chat_messages` on a player report (`from_player_id`, the reported player's or `null`, `text`, `sent_at`); Zaisma's own code: `reports.reported_chat_json`, `ReportedChatMessage`, `REPORTED_CHAT_LIMITS` | `room.chat(text, { toPlayerIds })` answers `{ sentAt }` (`ChatSent`); the `chat` event's `ChatMessage`: `fromPlayerId`, `text`, `hasSwearing`, `hasSlur`, `sentAt`; game server `onChat(state, player, room, chatInfo)` with `ChatInfo` `{ text, toPlayerIds }`, answering a `ChatAnswer` (`true`, `false`, `{ toPlayerIds }`); option `adultChatFilterEnabled`; `CHAT_ROOM_LIMITS` (`maximumChatMessageCount`, `chatWindowDurationMs`); wire messages `chat`, `chat_sent`, `chat_stopped` with a `chatNumber`; error codes `chat_stopped` (with `reason`, `stopped_by_game` for onChat), `chat_not_allowed`, `chat_empty`, `chat_too_long`, `chat_too_fast`, `chat_not_here` |
| Anyone under 18 types only where two independent players read it: who counts, and a player's network for it (never shown to a game) | Zaisma's own code: `CHAT_WITNESS_LIMITS` (`minimumWitnessCount`, `minimumWitnessAccountAgeDays`, `minimumWitnessCountedDayCount`), `isEstablishedWitness`, `independentWitnessCount`, `WitnessReader`; a network is `v4:<address>` or `v6:<the /56>` (`networkOfAddress`, `networkOf`, `sealNetwork`, `openNetworkSeal`); the filter's answer in rooms adds `readerPlayerIds` and `isEveryReaderNeeded` | player pass claim `network_seal`; `deliverChat`'s `isEveryReaderNeeded` |
| Voice in a room: a player's voice going through Cloudflare's media server to the players who may hear it, by chat's rules; who hears whom is decided by Zaisma, never the game | `who_hears_my_voice` (`friends`, `my_age_band`, `everyone`, outside the presets, starting where `who_reads_my_chat` is), `voice_hearing_enabled`; a game's `microphone_enabled` (off by default: only then may its frame use the microphone; `bad_microphone_enabled`); `voice_size_bytes` and the meter share `voice`; Zaisma's own code: `VOICE_LIMITS`, `voicePulls`, `accounts.who_hears_my_voice`, `voice_sessions` | `room.voice` (`join`, `leave`, `setMicrophoneMuted`, `setSpeakerVolume(playerId, volumePct)`, `setSpeakerPan(playerId, panPct)`, `audioNodeOf`, `speakerPlayerIds`, `canTalk`), events `speaking` and `voiceSpeakers`; `room.canTalk`; `canVoiceChat(speaker, listener)`; errors `microphone_refused`, `voice_not_allowed`, `voice_unavailable`, `voice_not_here` |
| The guide: Zaisma's one panel about you on every page and beside every game, its places and the player card; Zaisma's own sound for every game; a friend's invite into a room | Zaisma's own code: `accounts.game_volume_pct`, `accounts.game_sound_enabled`, `accounts.voice_volume_pct` (`/guide/sound`), `room_invites` (`sender_account_id`, `recipient_account_id`, `sent_at_ms`, `shown_at_ms`; `/guide/invite`, its `server_url` for a room on the game's own server and its `invite_status`; errors `bad_server_url`, `not_in_room`), the presence answer's `invites` (`room_invite_id`, `sender_name`, `game_title`, `room_link_path`), each account's bell (`BellObject`, `BELLS`, `/api/bell`; its messages' `kind` `invite` or `invite_gone` with `room_invite_ids`; the page's `zaisma:invites` and `zaisma:invite-gone`), a room link's room gone (`isRoomThere`, `is_there`, `isRoomGone`), the guide's inbox (`/guide/dismiss` with `inbox_notice_id`, its `inbox_notice_status` `archived`, error `no_inbox_notice`; `/guide/clear`, its `cleared_notice_count`), `GUIDE_PLACES`, `GUIDE_PAGES`, `zaismaGuide`, `zaismaSound` | `Zaisma.page.openPlayerCard(playerId)`, `Zaisma.page.leave()`; the page's messages `zaisma:open-player-card`, `zaisma:leave`, `zaisma:sound` (`gameVolumePct`, `isGameSoundOn`, `voiceVolumePct`) and `zaisma:sound-request` |
| The game view: while a game plays it gets every input, as an app would (full screen with the keyboard held where it can be, the phone held to the game's orientation, the screen kept awake, the leave check, and none of a website's zoom, highlighting, menus, page scrolling, shortcuts, dragging or focus hopping), each until the game turns it back | Zaisma's own code: `GAME_VIEW_SCRIPT`, `zaismaGameView` (`start`, `leave`), `zaismaGuide.leaveTo`; the frame's script `_zaisma/game-view.js`; the page's messages `zaisma:game-view` (`gameView`) and `zaisma:first-press`; the game's start, Play pressed inside the game's frame so its sound starts with it: `_zaisma/start` (`start.js`, `start_url`, `openGameFrame`, `__zaismaOpenInPlace`, `__zaismaOpenedAtMs`) and its messages `zaisma:start-ready`, `zaisma:start-pressed`, `zaisma:start-pointer` (`is_pointed`, `is_pressed`), `zaisma:start-focus` (`is_focused`), `zaisma:start-tab` (`is_backward`) and `zaisma:start-open` (`url`) | `Zaisma.page.setGameView(changes)`, `GameView` (`fullScreenEnabled`, `screenAwakeEnabled`, `leaveCheckEnabled`, `zoomEnabled`, `textSelectionEnabled`, `browserMenuEnabled`, `pageScrollEnabled`, `browserShortcutsEnabled`, `dragEnabled`, `keyboardFocusEnabled`); error `bad_game_view` |
| A voice group: the players who hear one another only, like a team or a squad's radio; heard speakers: whom one player hears, for proximity; how many voices a player hears at once, the loudest past it | | `room.setVoiceGroup(playerId, groupName)`, `room.setHeardSpeakers(listenerPlayerId, speakerPlayerIds)`, `room.setHeardSpeakerCount(count)`, `VOICE_ROOM_LIMITS` |
| A voice channel: voice for players of a game on its own server, joined with a voice ticket the server signs with the game's ticket secret | `create_ticket_secret`, `ticket_secret`, `has_ticket_secret`; errors `voice_ticket_required`, `voice_ticket_refused`; Zaisma's own code: `games.sealed_ticket_secret` | `voiceTicket(playerPass, channelName, ticketSecret, voiceTicketOptions)`, `VoiceTicketClaims` (`ticket_kind` `voice`, `channel_name`, `voice_group_name`, `heard_speaker_ids`, `heard_speaker_count`), `room.voice.join({ ticket })`, `room.voice.updateTicket` |
| A report's voice clip: the last 30 seconds of voice the reporter heard, from their game; only Zaisma hears it | Zaisma's own code: `reports.reported_audio_key`, `reportAudioKey` | `voiceClipBase64` on a report a game sends |
| An account's Zaisma friends, and the invite that makes two accounts friends | | player pass claim `friend_player_tag_ids` (their `player_tag_id`s, never their player IDs), checked with `passesAreFriends(first, second)`; `room.areFriends(firstPlayerId, secondPlayerId)`; a friend invite's `invite_code` is 8 letters and digits, shown as `K7Q2-MX9P` |
| A player's friends playing this game, the room to join each in, and why not | `server_url` (in Zaisma's own code: a room on the game's own servers) | `Zaisma.friends.list()` answers `{ friends }`, each `{ id, name, username, roomCode, serverUrl, joinRefusal }`; `joinRefusal`: `game_not_taking_joins`, `friend_not_taking_joins`, `private_room`, `room_closed`, `room_full`, `spectators_full`, `friend_not_in_room`; `Zaisma.friends.setRoom({ serverUrl, roomCode, friendJoinsEnabled })` (null when the player left), refused with `unlisted_server`; a friend's Join link's `?server=`, read as `Zaisma.rooms.linkedServerUrl` |
| A block between two players, either way (never who made it, never anyone's list of blocks) | | `room.hasBlockBetween(firstPlayerId, secondPlayerId)`; player pass claims `player_tag_id` (the account's own `player_tag_…` ID, different in every game) and `block_player_tag_ids` (the player tags of the accounts it has a block with), checked with `passesHaveBlockBetween(first, second)`; the room's `{ type: "blocks", playerIds }` to each player; a game's `{ type: "block", playerId }` and `{ type: "unblock", playerId }`; `room.block(playerId)`; quickJoin's hello `avoidBlockedPlayers: true`, turned away with `blocked_player_here` |
| Whether Zaisma's Join (friends on zaisma.com, `Zaisma.friends`) takes players into a game's rooms, or into one room, and whether a game joins players by itself | `friend_joins_enabled`, error `bad_friend_joins_enabled`; `quick_joined_at_ms` (Zaisma's own code) | `friendJoinsEnabled` in `joinRoom`, `quickJoin`, `room.reserve` and the room's settings; `room.setFriendJoinsEnabled(isEnabled)`; every hello from quickJoin says `isQuickJoin: true`; a Join picked while already playing reaches the running game first (the page's `zaisma:join-room` with `requestNumber`, `roomCode`, `serverUrl`, `isSpectator`, answered with `isTaken`), as a `move` or `moved` with `isAskedByPlayer` |
| What Zaisma's chat filter stopped, and why (one set of reasons everywhere), and what it only flags | `reason`: `contact_details`, `chat_paused`, `too_long`, `not_allowed_to_chat` (too few witnesses, or own servers' `checkChat` refusing a receiver), and from own servers' `checkChat` `unchecked` when Zaisma can't be reached; `personal_details`, `sexual` and `slur` are v1's, no longer given; a message kept for review before the chat review AI went is a `chat_review_…` ID, `chat_review_id` in the admin MCP | `Zaisma.checkChat` and the game server's `checkChat` answer `isAllowed`, `reason` (`ChatCheckReason`, the same values), `message` (the words the sender sees), `hasSwearing` and `hasSlur` (allowed, flagged for the game), as a `ChatCheck`; `adultChatFilterEnabled` and `isAdultFilterEnabled` stop contact details between adults too |
| What a game needs a Zaisma account for | `account_requirement`: `none`, `multiplayer`, `whole_game`; a guest turned away gets `account_needed` | error `code` `account_needed` |
| A game asking a guest to sign in while it runs, and the guest saying Not now | | `Zaisma.player.signIn()`; error `code` `sign_in_declined` |
| A secret kept in the database under a key the database never holds (`packages/core/src/sealed-secrets.ts`), and what finds it | `sealed_signing_secret`, `sealed_token`, never in an answer; `token_sha256`. The key's two slots: `STORED_SECRETS_KEY`, `SECOND_STORED_SECRETS_KEY`, and `IS_SECOND_STORED_SECRETS_KEY_IN_USE`, the same shape for each replaceable key (`scripts/replace-key.mjs`) | |
| A developer's own site or app that players sign in to with Zaisma, and OAuth's client type for it | `sign_in_app_id` (the OAuth `client_id`); `kind`: `confidential`, `public` | |
| Where a sign-in can go back to, and asking for a new client secret | `redirect_urls`; `replace_client_secret: true`, answered once as `client_secret` | |
| What an API key may do, and on which games | `access`: `api_key_name`, `access_level` (`read`, `upload`, `publish`, `full`, `custom`), `area_access` (each area's choice: `game_access`, `version_access`, `stats_access`, `database_access`, `save_access`, `purchase_access`, `forum_access`, `sign_in_app_access`, `webhook_access`, `credit_access`, `stripe_account_access`; choices `none`, `read`, `write`, and for versions `upload`, `publish`), `game_slugs` (`null` for every game); refused with `key_not_allowed` | |
| An AI app that connects to the MCP by signing in (OAuth's client), and the connection it makes | `mcp_client_id` (the OAuth `client_id`: an `mcp_client_…` ID, or its metadata document's URL); on `list_api_keys` items, `kind` (`api_key`, `connected_app`) and `connected_app_host` | |
| An address a developer's server takes Zaisma's events at (or the game's own game server), the events it takes and the games they're about | `webhook_id`; `destination_kind` (`endpoint_url`, `game_server`), `endpoint_url` (`null` for a game server), `event_kinds`, `game_slugs` (`null` for every game; a game server's one game) | `onWebhook(event, server)` (`WebhookEvent`, the same JSON), `WEBHOOK_LIMITS`; on your own server, POSTs at `/v1/webhooks` checked with `ZAISMA_WEBHOOK_SIGNING_SECRET` |
| What a player tells a game's developer from inside the game, a moment they marked while playing, and where the game says they are | `feedback`, its `id` a `feedback_…` ID: `feedback_kind` (`loved_this`, `idea`, `something_off`, `how_it_went`), `how_it_went` (`good`, `okay`, `bad`), `player_text`, `picture_url`, `marks` (each `at_session_sec`, `picture_url`), `game_context` (its `facts`, each `name` and `text`), `device_kind`, `browser_name`, `session_duration_sec`, `is_from_guest`, `sent_at`, `replied_at`, `reported_at`; tools `get_feedback` (its list `feedback_entries`), `reply_to_feedback`, `report_feedback` (`report_reason`: `abusive`, `real_life_threat`, `personal_details`, `sexual`); errors `no_feedback`, `no_feedback_picture`, `feedback_from_guest`. Inside: `feedback`, `feedback_stops`, `sender_key`, `FEEDBACK_LIMITS` | `Zaisma.page.openFeedback`, `Zaisma.page.setFeedbackContext`, `gameContext`, `FeedbackContext`, `markMomentEnabled`; errors `feedback_not_sent`, `feedback_not_opened`, `bad_game_context` |
| What a webhook is sent, and what happened | `webhook_event`, its `id` a `webhook_event_…` ID; its `kind`: `bug_reported`, `player_reported`, `scan_status_changed`, `live_version_changed`, `review_status_changed`, `country_blocks_changed`, `game_server_error_found`, `alert_raised`, `account_deleted` (with `account_deletion` `{ player_id, deleted_account_erase_enabled }`, and `game` or `sign_in_app`), `security_alert` (with `security_event`), `purchase_completed` and `purchase_refunded` (with `purchase`), `feedback_sent` (with `feedback`), `test`; when Zaisma made it: `created_at`; what it carries: `game`, `version`, `bug_report`, `player_report`, `game_server_error`, `alert`, `account_deletion`, `sign_in_app`, `security_event`, `purchase`, `feedback`. The game server gets it as the API's JSON, snake_case: the one exception to camelCase there | `WebhookEvent`, `WebhookEventKind`, `AccountDeletion`; `verifyWebhook` and `runWebhook` errors `{ error: { code, message, fix } }` |
| Asking for a new signing secret for a webhook | `replace_signing_secret: true`, answered once as `signing_secret` (`whsec_…`, Standard Webhooks' form) | |
| An event on its way to one webhook, and how it went | `delivery_status`: `pending`, `delivered`, `failed`; `attempt_count`, `last_attempt_at`, `next_attempt_at`, `failure_message`; `pending_delivery_count`, `failed_delivery_count`, `is_last_delivery_failed` | |
| The youngest age that can play a game, in years: 13, 16 or 18; never a band name. A younger account turned away gets `game_not_open_to_player` | `minimum_player_age_years`; errors `bad_minimum_player_age`, `accounts_needed_for_minimum_age` | error `code` `game_not_open_to_player` |
| How many players, and the most and fewest allowed | `player_count`, `maximum_player_count`, `minimum_player_count` | `playerCount`, `maximumPlayerCount`, `minimumPlayerCount` |
| Players who watch a room without playing: how many, the most a room takes, joining to watch, and their handlers | `spectator_count`, `maximum_spectator_count` | `maximumSpectatorCount`, `room.spectators`, `isSpectator` (joinRoom's option, `room.isSpectator`, `joinInfo.isSpectator`, a hello's), `spectatorCount`, `onSpectatorJoin(state, spectator, room)`, `onSpectatorLeave(state, spectator, room)`, `Zaisma.rooms.isLinkedAsSpectator` (a link's `watch=1`); errors `spectators_full` (no room for another spectator), `already_playing` (a player in the room asked to watch it) and `spectator_cannot_send` |
| Who a broadcast reaches | | `audience`: `everyone` (the default), `players`, `spectators`, in `room.broadcast` and `room.broadcastBytes` |
| How many files, and their total size | `file_count`, `size_bytes` | |
| An image's size on screen | `width_px`, `height_px` | |
| Counted plays, and time on screen in them | `play_count`, `play_duration_min` | |
| Player time in rooms and data through the relay | `room_play_duration_min`, `room_play_duration_hours`; `relayed_size_bytes` | |
| The time a game's own game server ran, in its rooms and outside them (requests, schedule runs, webhooks), its startup included, all of it priced | `game_server_cpu_duration_sec`; in Zaisma's own code `game_server_cpu_duration_ms`, `outside_room_cpu_duration_ms`, `game_server_startup_cpu_duration_ms` | `HOSTING_PRICES.gameServerCpuCentsPerSec` (Zaisma's own code) |
| Where a game's hours went this month | `play_hours` on `hosting_use_this_month`: `total_duration_hours`, `new_player_duration_hours`, `returning_player_duration_hours`, `rented_network_duration_hours`, `other_network_duration_hours`, `rented_share_used_pct` |
| A network Zaisma counts as rented servers, and the part of a game's meter its traffic gets | a rented network; the rented share: error `rented_share_used` |
| A browser's signed first play of a game, kept only in the browser | `play_mark` |
| A door's input refused by its stated shape | error `wrong_shape` |
| A game's free hosting this month and what used it: one meter, a percentage, never dollars | `hosting_use_this_month`: `free_used_pct`, `second_free_allowance_month_start_date` (alert `second_free_allowance_started`), `free_rooms_stopped_at` (alert `free_rooms_stopped`), `shares` (each `{ kind, share_pct }`, `kind` one of `rooms`, `game_server`, `relayed_data`, `database`, `requests`), `is_paused`, `paused_reason` (`free_used`, `budget_used`, `credit_used`, `no_real_players`, `free_hosting_ended`, `null`), `paused_at`, `resets_on_date`, `monthly_budget_cents`, `spent_from_credit_cents`, and the counts `room_play_duration_hours`, `room_awake_duration_hours`, `room_connection_count`, `inbound_message_count`, `relayed_size_bytes`, `game_server_cpu_duration_sec`, `startup_cpu_duration_sec`, `game_server_session_count`, `game_server_invocation_count` (every call into the game server as Cloudflare counts it, starts, requests, schedules and webhooks included, which the meter prices; not the stats' `game_server.call_count`, its rooms' calls for its health), `loaded_version_count`, `outside_call_count`, `log_file_count`, `request_count`, `awake_duration_hours`, `database_call_count`, `written_row_count`, `read_row_count`, `bookkeeping_written_row_count`, `database_size_bytes`; refused with `hosting_paused`. Inside: `game_hosting_months` (`used_cents`, `charged_cents`, `written_off_cents`, `paused_at_ms`, `paused_reason`), `room_usage`'s counts (`room_awake_duration_sec`, `room_connection_count`, `object_request_count`, `game_server_session_count`, `game_server_startup_cpu_duration_ms`, `outside_call_count`, `object_awake_duration_sec`, `bookkeeping_written_row_count`, `log_file_count`, `database_call_count`, `database_awake_duration_sec`), `loaded_versions`, `HOSTING_PRICES`, `OUTSIDE_CALL_CPU_DURATION_MS`, `FREE_HOSTING_CENTS_PER_MONTH`, `hostingCostCents`, `hostingUseThisMonth`, `isHostingPaused`, `AwakeTime` | `hosting_paused` (a room's refusal, a request's error, a database error) |
| What a game may draw from its developer's credit each month | `monthly_budget_cents` on a game (`null`: no paid hosting); error `bad_monthly_budget_cents`; alerts `hosting_budget_nearly_used`, `hosting_paused` with `budget_used` | |
| A developer's credit | `credit`: `balance_cents`, `is_credit_low` (and the `credit_low` alert), `waiting_spending_requests` (on `get_credit`), `top_ups` (each `{ id, amount_cents, refundable_cents, refund_ends_at, created_at }`), `games` (each `{ slug, title, monthly_budget_cents, spent_from_credit_this_month_cents, last_month_beyond_free_cents }`), `entries` (each `{ id, entry_kind, amount_cents, game_slug, created_at }`, `entry_kind` one of `top_up`, `hosting_charge`, `refund`, `written_off`); a top-up's `amount_cents`, Stripe's `checkout_url`; `refunded_cents`; key area `credit_access`; `credit_balance_cents` in `get_access`; tools `get_credit`, `top_up_credit`, `refund_top_up`, `get_spending_request` (answers `spending_request`: `{ id, request_kind, game_slug, game_title, requested_change, current_setting, request_status, created_at, expires_at, answered_at }`; `confirmation_needed` adds `spending_request_id`); errors `no_spending_request` (`request_kind` is `game_budget` or `credit_plan_refill_level`; `request_status` is `waiting`, `approved`, `declined` or `expired`, which is never stored, only answered a day after the ask); errors `confirmation_needed` (with `confirm_url`), `account_not_protected`, `bad_top_up_amount`, `no_top_up`, `top_up_not_refundable`, `stripe_unavailable`. Inside: `credit_entries`, `owners.credit_balance_cents`, `owners.credit_low_line_cents`, `pending_refunds` (a deleted account's refund Stripe hasn't taken yet; `pending_refund_…` IDs), `CREDIT_LIMITS`, `creditOf`, `isCreditLow`, `addCreditEntry`, `refundableTopUps` | |
| The monthly credit plan | Always "credit plan", never "plan" alone (that's `free` or `pro`) or "subscription": `credit_plan` on `credit` (`null` with none): `{ refill_level_cents, plan_status, next_payment_at, next_payment_cents, started_at }`, `plan_status` `running` or `payment_failing`; input `refill_level_cents`; tools `start_credit_plan`, `change_credit_plan`, `stop_credit_plan`; errors `bad_refill_level_cents`, `already_credit_plan`, `no_credit_plan`; spending request kind `credit_plan_refill_level` (its change `{ refill_level_cents }`); emails `credit_plan_payment_failed`, `credit_plan_stopped`. Inside: `owners.credit_plan_subscription_id`, `credit_plan_refill_level_cents`, `credit_plan_status`, `credit_plan_started_at_ms`, `credit_plan_event_at_ms`, `spending_requests.refill_level_cents`, `CREDIT_LIMITS.minimumRefillLevelCents`, `maximumRefillLevelCents`, `minimumRefillCents`, `creditPlanCheckout`, `addRefillToInvoice`, `stopCreditPlan`, `STRIPE_CREDIT_PLAN_PRICE_ID`, Stripe metadata `subscription_kind` (`pro`, `credit_plan`) | |
| What an account stores | `storage`: `{ stored_size_bytes, included_size_bytes, maximum_stored_size_bytes, allowance_kind, new_data_today_size_bytes, maximum_new_data_size_bytes, monthly_storage_budget_cents, unpaid_files_delete_at, spent_this_month_cents, price_per_gigabyte_month_cents, deletable_versions }`; "stored" is what the account keeps, "included" what it has with no budget, "new data" what it sends that it didn't already store (`owner_new_data_days`); `allowance_kind`: `new`, `established`, `paid_by_card`, `pro`; credit entry `storage_charge`; errors `storage_full`, `new_data_limit`, `bad_monthly_storage_budget_cents` | |
| Deleting a version or a game | `delete_version`, `delete_game` with `confirm_slug`; `is_deleted`; errors `version_in_use`, `kept_for_review`, `bad_confirm_slug`; a file no version of the owner's uses is released (`released_at_ms`) and stops counting | |
| A game waiting to be erased | `erases_at` on the game (`null` for any other), `is_erase_now_allowed`, `bring_back_game`, `erase_game_now`, and `game_deletion_request` with `request_kind` `delete_game` or `erase_game_now` |
| A developer's plan and its limits | `plan`: `free` or `pro` (never "subscription" or "tier"); `pro`: `{ plan, pro_ends_at, is_pro_cancelled, monthly_price_cents, limits: { free, pro }, limits_for_everyone, used_today }`, each plan's limits `{ maximum_performance_check_count, included_size_bytes, maximum_new_data_size_bytes }`, `limits_for_everyone` `{ maximum_version_count }`, `used_today` `{ performance_check_count }`; Stripe's `checkout_url`; `plan` in `get_access`; key area `credit_access`; tools `get_pro`, `start_pro`, `cancel_pro`, `resume_pro`; errors `already_pro`, `not_pro`. Inside: `owners.pro_until_ms`, `is_pro_cancelled`, `stripe_subscription_id`, `PLAN_KINDS`, `PLAN_LIMITS`, `PRO_PRICE_CENTS_PER_MONTH`, `planOf`, `limitsFor`, `proCheckout`, `setProCancelled`, `STRIPE_PRO_PRICE_ID` | |
| A developer's own Stripe account, where the buy sheet's sales go (Connect Standard: the developer is the seller, no fee) | `stripe_account`: `is_connected`, `stripe_account_id` (Stripe's `acct_…`, not a Zaisma ID, so it says no kind), `can_take_payments`, `country_code`, `default_currency_code`, `business_name`, `support_email`, `is_stripe_tax_used`, `connected_at`, `balance` (Stripe's own figures, read live: `currency_code`, `available_minor_units`, `pending_minor_units`, `other_currency_balances` (each `{ currency_code, available_minor_units, pending_minor_units }`), `next_payout` (`{ amount_minor_units, currency_code, arrives_at }`); `null` when Stripe doesn't answer in 3 seconds); key area `stripe_account_access`; tools `get_stripe_account`, `connect_stripe_account`, `update_stripe_account`, `disconnect_stripe_account`; errors `stripe_not_connected`, `stripe_cannot_take_payments`, `bad_is_stripe_tax_used`. Inside: columns `stripe_account_id`, `can_take_stripe_payments`, `stripe_country_code`, `stripe_default_currency_code`, `stripe_business_name`, `stripe_support_email`, `is_stripe_tax_used`, `stripe_connected_at_ms` | |
| The link a developer connects their Stripe account on | `connect_url`, `expires_at` (10 minutes), answered by `connect_stripe_account` (`POST /stripe-account/connection-links`); through a key, `confirmation_needed` with `confirm_url` | |
| Whether Stripe Tax works out and records the tax inside each price (prices never change with it) | `is_stripe_tax_used`, `true` or `false`, in `update_stripe_account` and the `stripe_account`; error `bad_is_stripe_tax_used` | |
| Zaisma's sheet a player buys an item on, over the game or in a window, and how a buy ends | the buy sheet; errors `not_for_sale`, `stripe_not_connected`, `stripe_cannot_take_payments` | `Zaisma.items.buy(itemName, { itemCount, gameAccountId })` answers `BuyResult` `{ status, purchase }`, `status` `bought`, `cancelled`, `failed`; `Zaisma.items.on("sheetOpen" or "sheetClose", listener)` with `SheetEvent` `{ itemName }`; error `code` `needs_player_tap` |
| A player's saved card and the purchase PIN that confirms it's them (the player side of the buy sheet; the sheet's own `/api/buy`, `/api/payment-methods` and `/api/account/purchase-pin` calls) | `saved_card` `{ card_brand, card_last_digits }` (`card_brand` Stripe's lowercase brand, like `visa`; `card_last_digits` the card's last four digits as text, never a number, so `0042` keeps its zeros), `purchase_pin` as the input (exactly 6 digits, as text, so `048213` keeps its zero) and only ever stored hashed as `purchase_pin_hash`, `has_purchase_pin`, `purchase_pin_failed_count`; how a buy confirms it's the player: `confirmation_method` one of `passkey`, `purchase_pin`, `password`, in the body as `passkey_tap`, `purchase_pin` or `password`, and a device's confirm kept in `purchase_confirmations` (15 minutes; a purchase PIN account's covers one buy, and so does one with no `buying_public_key_base64`); a browser's buying key, an ECDSA P-256 pair it keeps: `buying_public_key_base64` (the raw public half, sent to the sheet's start, confirm and pay calls, and kept by a confirm in `buying_keys`) and `buying_signature_base64` (its signature over the purchase, sent to the pay call), error `bad_buying_key`; on the sheet `is_confirmation_needed`, `confirmation_reason` (why: `purchase_pin`, `new_device` (no kept buying key signs this buy), `old_sign_in`, `big_spend`, or `null` when pressing Buy is enough; `is_confirmation_needed` is `confirmation_reason !== null`), `confirmation_methods` `{ has_passkey, has_purchase_pin, has_password, is_purchase_pin_locked }`, `is_eu_withdrawal_line_shown`, `refund_policy_words`, `has_account_email` (a saved card's receipts go to the account's email); player-side error codes `account_needed` (a guest), `account_protection_needed` (saving a card or setting a PIN needs a passkey or an email on the account), `already_owned` (a permanent item the player has), `purchase_confirmation_needed` (confirm it's you, then buy again), `purchase_pin_locked` (5 wrong PINs: a password confirm unlocks it), `wrong_purchase_pin`, `wrong_passkey`, `no_purchase_pin`, `bad_purchase_pin`, `card_not_saved`, `payment_declined` | `PURCHASE_PIN_LIMITS` `{ pinDigitCount, maximumFailedTryCount, confirmationDurationMin, signInMaximumAgeDays, dailySpendLimitUsdMinorUnits }`, `APPROXIMATE_USD_PER_CURRENCY_UNIT`, `approximateUsdMinorUnits`, `hashPurchasePin`, `isPurchasePin`, `purchasePinProblem`, `PURCHASE_LIMIT` (the 20-a-minute rate limit binding) (Zaisma's own code) |
| How much of a sale to refund, and what is left | `amount_minor_units` in `refund_purchase` (left out: all that's left; a full refund takes the item back, a partial one leaves it), `refunded_minor_units` on the purchase; errors `bad_amount_minor_units`, `purchase_not_paid`, `already_refunded` | |
| Bytes a game and its room send each other, and whose they are | | `room.sendBytes(bytes)` and the `"bytes"` event `(bytes, fromPlayerId)` in the SDK, error `code` `bad_bytes`; `onBytes(state, player, room, bytes)`, `room.broadcastBytes(bytes, { exceptPlayerId, fromPlayerId })`, `room.sendBytes(playerId, bytes)` on the game server |
| A game's room traffic: messages and bytes each way per player a second, its message types, and what to change | `inbound_messages_per_player_sec`, `inbound_size_bytes_per_player_sec`, `outbound_messages_per_player_sec`, `outbound_size_bytes_per_player_sec`; `room_traffic` with `message_types` (`message_type`, `direction`: `inbound`, `outbound`, `average_size_bytes`, `largest_size_bytes`) and `traffic_hints` (`code`: `json_messages_large`, `outbound_heavy`, `message_near_limit`, `latest_only_available`, `input_frequent`); `message_type` `(state)` for state sync's updates. Inside: `room_message_types.backed_up_message_count` | `STATE_MESSAGE_TYPE`, `backedUpMessageCount` (Zaisma's own code) |
| How many days a report or stats answer covers | `period_duration_days` | |
| What the game check finds before an upload | `problems`, each `{ code, problem_kind, is_fixed_by_upload_command, message, path, quote, fix }`, `problem_kind` `refused` or `broken`; `omitted_problem_count` | |
| A version's scan result, and what it found that holds or rejects it | `scan_status`: `scanning`, `held`, `approved`, `rejected`; `findings`, each `{ code, severity, message, content_rule, path, fix }` | |
| How a version started in headless Chrome, and what would make it much smaller (notes, never holds) | `performance_check`: `{ check_status, checked_at, browser_description, loading_duration_sec, start_download_size_bytes, start_file_count, start_memory_size_bytes, longest_start_task_duration_ms, notes }`, `check_status` `waiting`, `checking`, `checked`, `over_daily_limit`, `could_not_run`; a performance note `{ code, message, path, saved_size_bytes, fix }`; the game check's `performance_notes`. Inside: `performance_checks.start_files`, each `{ path, destination, is_cors_request, downloaded_size_bytes }` | `PERFORMANCE_CHECK_LIMITS` |
| How a game runs on players' devices, as totals (never per player), and the switch for it | `performance` in `get_stats`: `version_totals` and `device_totals`, each row `{ version_id, play_count, median_loading_duration_sec, slow_tenth_loading_duration_sec, median_frames_per_sec, low_tenth_frames_per_sec, long_frames_per_min, crashed_play_pct, error_stop_count, context_lost_count, stopped_responding_count, median_peak_memory_size_bytes, is_measured }`, a device row also `browser_name` (`chrome`, `edge`, `firefox`, `safari`, `samsung_internet`, `other`), `os_name` (`windows`, `macos`, `linux`, `chromeos`, `android`, `ios`, `other`), `device_kind` (`computer`, `phone`, `tablet`; `other` only in the folded row) and `graphics_family` (`nvidia`, `amd`, `intel`, `apple`, `qualcomm`, `arm`, `imagination`, `other`, `unknown`); the game's `performance_measuring_enabled`, error `bad_performance_measuring_enabled`. Inside: `performance_days` (`loading_counts`, `frame_rate_seconds`, `memory_counts`: JSON arrays of counts by bucket), `play_tickets.has_performance_loading`, `has_performance_crash`, `measured_duration_sec`; page messages `zaisma:performance`, `zaisma:alive` | `LOADING_BUCKETS_SEC`, `FRAME_RATE_BUCKETS`, `MEMORY_BUCKETS_BYTES`, `BROWSER_NAMES`, `OS_NAMES`, `DEVICE_KINDS`, `GRAPHICS_FAMILIES`, `CRASH_KINDS`, `PLAYER_PERFORMANCE_LIMITS`, `browserOf`, `osOf`, `percentileOf`, `frameRateAt` |
| A sample game in the review test set, and what a run found | `is_honest`, `content_rule`, `protection`, `why` (in `case.json`); `outcome`: `held_bad`, `missed_bad`, `passed_honest`, `held_honest`, `inconsistent` (Zaisma's own code) | |
| Zaisma's review of a game | `review_status`: `pending`, `live`, `held`, `removed` | |
| Why Zaisma held, rejected or took down a game, version or image | `review_reason`: `{ code, message, content_rule, fix }`, its `code` from `REVIEW_CODES` | |
| The countries a game is blocked in on a notice under their law | `country_blocks`, each `{ country_code, country_name, review_reason, blocked_at }`; the `game_blocked_in_country` alert, the `country_blocks_changed` webhook. Inside: `games.country_blocks`, each `blocked_at_ms` | |
| What needs a developer's attention in a game | `alerts`, each `{ kind, message, fix, version_id }`, `kind` one of `game_removed`, `game_waiting_to_erase`, `game_held`, `game_blocked_in_country`, `version_rejected`, `version_held`, `link_flagged`, `hosting_paused`, `free_rooms_stopped`, `second_free_allowance_started`, `database_full`, `hosting_nearly_paused`, `hosting_budget_nearly_used`, `credit_low`, `database_nearly_full`, `player_erase_failed`, `reports_open`; a heads-up is its paused or full kind with `nearly` (`nearly_used` for a budget) | |
| A content rule, as a hold or takedown names it | `content_rule`: `child_safety`, `sexual`, `malware`, `illegal`, `real_people`, `copyright`, `defamation`, `trademark`, `personal_details`, `chat`, `crypto`, `purchases`, `faked_plays` (the same words as a report's `reason` where they mean the same) | |
| Who can see a game | `visibility`: `draft`, `listed`, `unlisted`, `private` | |
| Where to continue a list | `cursor` in, `next_cursor` out | |
| A game server's logs, and where to read on from | `log_lines`, each `{ logged_at, level, text, source_kind, room_code, version_id }`; `level` a console method (`debug`, `log`, `info`, `warn`, `error`), `source_kind` `room`, `request`, `schedule` or `webhook`; filters `minimum_level`, `search_text`, `maximum_line_count`; `cursor` in and `next_cursor` out go back, `new_lines_cursor` in and out goes forward | `LOG_LIMITS`, `StoredLogLine`, `LogWriter` |
| How a game is played | `play_modes`: a list of `{ mode, minimum_player_count, maximum_player_count, play_style }` | |
| A version's notes for players, and when it goes live by itself | `patch_notes`, `scheduled_publish_at` | |
| A publish that's news, and the dates only it moves | `is_big_update` (input and on a version), `big_update_at` (a game's last), `recently_updated_at` (a game's place on Recently updated); `first_published_at` (a game's or a version's first time live, which never moves) | error codes `bad_is_big_update`, `big_update_needs_patch_notes`, `big_update_already_live` |
| Links, by what they open | `page_url` (a game's page), `preview_url` (a version), `image_url`, `link_url` (a tester link) | `inviteUrl` (a room's invite link), `serverUrl` (a game server of the developer's own) |
| What a tester link opens and until when, and when a preview link stops working | `version_choice`: `live`, `newest_passed`, `picked`; `picked_version_id`, `ends_at`; `preview_url_expires_at` | |
| Forum topics with something new from Zaisma | `unread_topic_count` | |
| What a player wrote in a report | `player_text` | |
| A report about one of a game's players, passed to its developer | `player_report`, in `player_reports`; who it's about: `reported_player_id`, `reported_player_name`; why: `reason`, one of `real_life_threat`, `personal_details`, `following_after_block`, `sexual`, `wrong_age`, `harassment`, `cheating`, `other` | |
| Reports about the same problem, named by the first one (admin MCP) | `report_group_id` (a `report_…` ID) | |
| Where a report stands | `report_status`: `open`, `dismissed`, `actioned` | |
| How serious a report or topic is (admin MCP) | `severity`: `child_safety` (reports only), `urgent`, `high`, `normal`, `low` | |
| What a person decides about reports, a precedent or a post, and why (admin MCP) | `decision`, `why` | |
| A ruling report triage follows, and where it stands (admin MCP) | `precedent_id`; `precedent_status`: `proposed`, `active`, `retired`; `replaces_precedent_id`, `followed_count` | |
| What report triage and forum sorting found (admin MCP) | `triage`, `sorting`, `is_waiting_for_sorting`; what triage did by itself is `ai_actions` | |
| Public forum posts waiting for a person (admin MCP) | `waiting_posts` | |
| What happened to a game, and who did it | `events`, each with `happened_at` and `last_happened_at`, `occurrence_count`, `subject_name`; `done_by`: `you`, `api_key`, `ai`, `zaisma`; `actor` in the admin MCP | |
| Where something came from | `device`, `network_name`, `city_name`, `region_name`, `country_code`, `connection_address`, `is_new_place` | |
| An account's activity | `get_activity`'s `events`, each with `kind` (the account kinds), `sign_in_kind` (`password`, `passkey`, `email_code`, `google`, `discord`) and `security_alert_status`; `unseen_security_alerts`; `where_used_from_enabled` | |
| A risky moment the owner hears about | a security alert, never just "alert" (a game's `alerts` are about its free use and reviews): `security_alert_status` `emailed`, `unseen` or `seen`; the `security_alert` webhook kind | |
| The calls that usually follow a change | `next_steps` | |
| Ticks a second, and the time since the last tick | | `ticksPerSec`, `tickDurationSec` |
| Time without input before "Still there?", and who checks | | `idleTimeoutSec` (30 to 86400, else error `code` `bad_idle_timeout` in the SDK), `idleCheck`: `server`, `client`, `off`; a player's game turns its own off with `idleCheckEnabled: false` |
| How long a seat is held for a player who walked away | | `seatHoldDurationSec` |
| How many of the game's rooms one player sits in at once | | `maximumRoomCountPerPlayer` (1 to 10, 1 by default; a newer seat past it closes the oldest with close code 4001, "Joined from somewhere else") |
| How long a player whose connection dropped stays in the match, and why a player in the room isn't playing | | `reconnectTimeoutSec`; `awayReason`: `idle`, `hidden`, `lost` or `null` (`room.awayReason(playerId)` on the game server, each `ListedPlayer` in `room.players` in the game) |
| When Zaisma will end a match after its game's hosting paused, and hearing it | | `endsAt` (an ISO time); the game server's `onEnding`, the SDK's `ending` event, the room's `{ type: "ending", endsAt }` |
| Zaisma calling that end off once the game's hosting starts again, and hearing it | | `endsAt` back to null; the game server's `onEndingCancelled`, the SDK's `endingCancelled` event, the room's `{ type: "ending_cancelled" }` |
| When running matches get a newly published version | `match_update_mode`: `next_match`, `now` (on a publish, and on a version that goes live by itself) | the game server's `onVersionUpdate(state, versionUpdate, room)` with `VersionUpdate` `versionId`, `appliesAt` (an ISO time) and `isReloading`, `room.applyVersionUpdate()`; for `next_match`, `onVersionAvailable(state, versionAvailable, room)` with `VersionAvailable` `versionId` and `isReloading`; why the page loaded, `Zaisma.page.reloadReason` (`version_update`, `player`, `null`) and the rooms it was in, `Zaisma.page.previousRoomCodes`; the bench's `POST /bench/api/version-updates`; the room's `versionUpdate` event with `versionId`, `appliesAt` (an ISO time) and `isReloading`; `Zaisma.versions.on("update")` and `update.apply()` for games not in a match; a hello's `versionId` (the version the player's game runs), turned away with `other_version` and the room's `versionId` when its game server runs another; `live_rooms.version_id` |
| How often a real-time room saves its state, and a room coming back from a restart with it | | `stateSaveIntervalSec`; the game server's `onRestored(state, restoreInfo, room)`, with `RestoreInfo` `savedAt` (an ISO time), `lostDurationSec`, `savedVersionId` and `keptRoomRestore`; the Node runner's `--room-state-file` (`startServer({ roomStateFile })`, table `room_states`: `room_code`, `format_version`, `state_json`, `saved_room_json`, `saved_at_ms`, `is_saved_empty`, `is_kept`; the keys inside `saved_room_json` are snake_case, like `known_player_ids`, `kept_out`, `ends_at_ms` and `match_players`); a real-time room (`ticksPerSec`) hears `onRestored`, a turn-based room doesn't |
| A player's conditions on the local bench, and what it starts again and counts (play-locally) | the bench's `PUT /bench/api/open-players/<player_number>/conditions` and the open player's `conditions`: `added_ping_duration_ms`, `jitter_duration_ms`, `maximum_bytes_per_sec` (`null` for no limit), `packet_loss_pct`, `device_speed_pct`; `POST .../drops` with `drop_duration_sec`, answering `drop_ends_at`; `POST /bench/api/restarts` with `restart_kind` `copy` or `room`, answering `room_count`; a room's `call_count`, `cpu_duration_ms`, `slowest_call_cpu_duration_ms`, `slowest_call_handler_name`, `over_cpu_call_count`, `stopped_count`, and `game_server_copy` (`copy_number`, `started_at`, `memory_size_bytes`, `maximum_memory_size_bytes`, `outside_rooms`); `GET /bench/api/log` with the logs' `search_text`, `maximum_line_count` and `new_lines_cursor` (`log_line_<number>`), answering `has_more_lines` and `missed_line_count`; errors `bad_added_ping_duration_ms`, `bad_jitter_duration_ms`, `bad_maximum_bytes_per_sec`, `bad_packet_loss_pct`, `bad_device_speed_pct`, `bad_drop_duration_sec`, `bad_restart_kind`, `no_game_server`, `bad_new_lines_cursor`, `bad_search_text`, `bad_maximum_line_count`. Inside: `CONDITION_LIMITS`, `ConditionedLink`, `deliveryAtMs`, `loadCopy`, `NUMBERS`, `MARK_STARTING` | |
| A message for a live room from another room, the game server outside rooms or the developer | `message`; tools `send_room_message`, `send_to_every_room`; `is_delivered`, `room_count`; errors `bad_room_message`, `room_busy`, `every_room_send_limit`; the bench's `POST /bench/api/room-messages`. Inside: `ROOM_MESSAGE_LIMITS`, `checkRoomMessage`, `GameRoomsService.sendRoomMessage` (`deliveryOutcome` `delivered`, `no_room`, `room_busy`) and `sendToEveryRoom` (`isLimited`), `RoomReachBinding`, the rooms' `/room-message` | `RoomMessage` (`message`, `senderKind` `room` \| `server` \| `developer`, `fromRoomCode`, `sentAt`), `ROOM_MESSAGE_SENDER_KINDS`; `room.sendToRoom(roomCode, message)` and `server.sendToRoom` answering `{ isDelivered }`, `room.sendToEveryRoom(message, roomSelection)` and `server.sendToEveryRoom` answering `{ roomCount }`; the handler `onRoomMessage(state, roomMessage, room)`; the room's `roomMessage` event; `ROOM_MESSAGE_LIMITS` (`maximumRoomMessageSizeBytes`, `maximumRoomSendsPerSec`, `maximumReceivedRoomMessagesPerSec`, `maximumEveryRoomSendsPerMin`, `maximumScheduledRoomMessageCount`, `maximumScheduleAheadDurationDays`, `maximumListedRoomCount`) |
| A send to every room scheduled for later | `scheduled_room_message` (`id`, `send_at`, `labels`, `created_at`), `scheduled_room_messages` (each with `message`, `sent_at`, `delivered_room_count`), `send_at`, `is_cancelled`; tools `list_room_messages`, `cancel_room_message`; errors `too_many_scheduled_room_messages`, `no_scheduled_room_message`, `bad_time`. Inside: `scheduled_room_messages` (`room_message_json`, `labels_json`, `send_at_ms`, `created_at_ms`, `sent_at_ms`, `delivered_room_count`), `sendDueRoomMessages` | |
| One of a game's rooms running now, as the game reaches it, and who's in one | `in_room_player_count` (on a game: players in its Zaisma rooms now), `rooms` (each `room_code`, `name`, `labels`, `player_count`, `maximum_player_count`, `spectator_count`, `is_listed`, `is_open`, `is_kept`, `version_id`, `continent`, `created_at`), `room_count`, `room`, `players` (each `player_id`, `name`, `kind`, `is_away`, `away_reason`, `joined_at`, `is_spectator`), `labels` (a list of `label_name` and `label_value`; as an input, which rooms: those holding every label), `is_kicked`, `is_ended`, `is_kept_out`, `confirm`; tools `list_rooms`, `get_room`, `kick_player`, `end_room`; errors `no_room`, `no_player_in_room`, `bad_labels`, `bad_kick_message`, `bad_end_message`; `zaisma rooms`. Inside: `listLiveRooms`, `liveRoomOf`, `LiveRoomRecord`, `GameRoomsService.getRoom`, `kickPlayer` (`kickOutcome`), `endRoom` (`endOutcome`) | `LiveRoom` (`roomCode`, `name`, `labels`, `playerCount`, `maximumPlayerCount`, `spectatorCount`, `isListed`, `isOpen`, `isKept`, `versionId`, `continent`, `createdAt`), `RoomPlayer` (`playerId`, `name`, `kind`, `isAway`, `awayReason`, `joinedAt`, `isSpectator`), `RoomSelection` (`labels`); `room.listRooms(roomSelection)` and `server.listRooms` answering `{ rooms }`, `server.getRoom(roomCode)`, `server.kickFromRoom(roomCode, playerId, kickOptions)` and `server.endRoom(roomCode, message)` answering `{ isDone }`. Inside: `RoomReach`, `ServerRoomReach`, `Transport.roomReach`, `newServer`, `RoomCore.receiveRoomMessage`, `RoomCore.roomPlayers` |
| A room that keeps its world when everyone leaves, sleeping until someone joins, and the game's storage it counts toward with the database | `kept_rooms` (each `room_code`, `name`, `saved_size_bytes`, `saved_at`, `last_played_at`, `created_at`, `erases_at`), `kept_rooms_size_bytes`, `waiting_kept_rooms_size_bytes`, `storage_size_bytes`, `maximum_storage_size_bytes`, `is_deleted`, `is_brought_back`, `is_erased`; `live_rooms.is_kept`; tools `list_kept_rooms`, `delete_kept_room`, `bring_back_kept_room`, `erase_kept_room_now`; errors `no_kept_room`, `kept_room_not_waiting`, `kept_room_erasing`; `zaisma kept-rooms` | `room.isKept`, `room.setKept(isKept)`; `isKept` in `room.reserve` and `ListedRoom`; Zaisma's own `Saved.isSavedEmpty` and the Node runner's `room_states.is_saved_empty` (saved as the room emptied: nothing lost) |
| What happens to a player who walks away | | `awayMode`: `hold`, `lobby` |
| A mistake in a game server's code, and how it fails | | a `GameServerError` with a `code` (`GameServerErrorCode`: `unknown_option`, `bad_option`, `bad_room_call`, `room_call_limit`, `room_call_unavailable`, `bad_handler_answer`), the `field` it is about (an option, a handler like `canJoin` or a room call like `room.kick`), and a `fix`; shown in the game's logs and `get_stats` errors |
| Starting a game server on your own machine, and what it answers | | `import { startServer } from "@zaisma/game-server/node"`: `startServer({ gameServer, gameSlug, port, origins, issuerUrl, loadPassKeys, loadReceiptKeys, loadProfile, database, secrets, webhookSigningSecret, roomStateFile, webtransportPort, certificatePath, certificateKeyPath, identifyPlayer, outsideGuestsEnabled })` answers `{ close, httpServer, fastLaneReady }`; the command `npx @zaisma/game-server <server.ts> --game <slug>` with `--port`, `--origin`, `--issuer-url`, `--database-file`, `--room-state-file`, and the fast lane's `--webtransport-port`, `--certificate-path` and `--certificate-key-path` (bin `zaisma-game-server`) |
| The fast lane to a game's own server (WebTransport), and what a room's connection uses | | `transport`: `websocket`, `webtransport` (`Zaisma.joinRoom`'s option, refused with `bad_transport`, and `room.transport`; `TRANSPORTS` in the SDK); `FAST_LANE_CONNECT_TIMEOUT_MS` (3000); `FastLane` (the SDK's adapter); `delivery` reaches the room's `send` and `sendBytes` (`Transport`) |
| Sending each player the game server's state, then only what changed, and what each player sees of it | | `stateSyncEnabled`; `stateView(state, viewer, room)`; the room's `{ type: "state", serverTimeMs, full }` and `{ type: "state", serverTimeMs, changes }`; a `StateChange` `[path, value]` or `[path]`; `room.state`, the `"state"` event `(state, changes)` and `room.smoothedState({ delayMs })` (`SmoothingOptions`) in the SDK, error `code` `bad_delay`; `ROOM_LIMITS.maximumStateViewSizeBytes`; in Zaisma's own code `diffState`, `applyStateChanges`, `newStateTracker` |
| A send that may be dropped for a newer one while a player's connection is backed up | | `delivery`: `reliable`, `latest_only`; `latestKey` (needed with `latest_only`); `SendOptions` in the SDK and on the game server, error `code` `bad_send_option`; a player's connection is backed up (`isBackedUp`, `ROOM_TUNING.backedUpSizeBytes`, `backedUpDelayMs`); `ROOM_LIMITS.maximumLatestOnlySlotCount`, `maximumLatestKeyCharacterCount` |
| What a game sends at once, going to the room as one message, and sends kept under the room's limit by waiting | | `sendCombiningEnabled` (joinRoom, on by default); the client message `{ type: "messages", data }` and welcome's `canCombineMessages`; `ROOM_LIMITS.maximumCombinedMessageCount`, `maximumCombinedGameMessagesPerSec`, `maximumCombinedGameMessageBurstCount` |
| A latest-only send the same as the last one with its latestKey, not sent | | `unchangedSkippingEnabled` (joinRoom, on by default) |
| A message between a game and its room, the game's own message in it, and the player it came from | | `type`, `data`, `fromPlayerId` (a send option on the game server, `null` for the game server's own); the `"message"` event `(message, fromPlayerId)`; `ClientMessage`, `ServerMessage` |
| Which room messages a game and its room speak | | `protocolVersionNumber` (a hello's and a welcome's), `PROTOCOL_VERSION_NUMBER` (1) |
| A quick join's hello asking for a room without anyone the player blocked (an action, so a verb) | | `avoidBlockedPlayers` |
| Why a match ended | | `endReason`: `game`, `no_players`, `hosting_paused`, `kept_room_deleted`, `game_unavailable`, `game_server_stopped` (`EndReason`); the `"ended"` event `{ message, endReason }` |
| Where the "Still there?" question stands | | `idleStatus`: `asking`, `answered`, `timed_out`, with `answerTimeoutSec`; the `"idle"` event (`Idle`) |
| A player back after walking away, and whether their seat was still held | | the `"back"` event `{ roomCode, isSeatHeld, rejoin() }` |
| Reliable sends waiting while a room isn't reachable | | `MAXIMUM_QUEUED_SEND_COUNT` (60, the SDK's); error `code` `send_queue_full` |
| How a room checks and paces its connections (not limits a game sets) | | `ROOM_TUNING`: `probeIntervalSec`, `probeAnswerTimeoutSec`, `probeSentSizeBytes`, `maximumUnansweredSentSizeBytes`, `maximumUnansweredProbeCount`, `backedUpSizeBytes`, `backedUpDelayMs` |
| Why a room closed a connection | | `ENDED_CLOSE_CODE` (4000: the match ended), `REMOVED_CLOSE_CODE` (4001: refused, removed or replaced), `SEAT_GONE_CLOSE_CODE` (4002: the seat is no longer held), `NO_ANSWER_CLOSE_CODE` (4003: no answer or too far behind), `VERSION_UPDATE_CLOSE_CODE` (4004: the match switches to a version published now), `BUSY_CLOSE_CODE` (1013) |
| What a player's game brings into a room, and what a room another room made starts with | | `joinData`, `setupData` |
| How a player came into a room, and why they left or walked away | | `joinInfo: { fromRoomCode, isReturning, isSpectator }`; `leaveInfo: { reason }`, `reason` one of `left`, `lost`, `idle`, `hidden`, `kicked`; `onAway(state, player, room, awayInfo)` with `awayInfo: { reason }` (`AwayInfo`), `reason` one of `idle`, `hidden`, `lost` |
| Words a person reads about what happened: an error's, a kick's, a refusal's, a match's end; on errors, findings and alerts, `message_for_people` is the page's text beside the caller's `message` and `fix` | `message`, `message_for_people` | `message`; `refusalMessage` in what `canJoin` answers (`true`, `false` or `{ refusalMessage }`; answering nothing or anything else turns the player away and is logged as `bad_handler_answer`) |
| The room's host, who can run it from the game, and whether a game server has one | | `hostPlayerId`, `hostControlsEnabled` |
| Whether a room shows in room lists, and takes new players | | `isListed`, `isOpen` |
| Rooms in a room list: everyone playing and their rooms, listed ones closed and with space, ones taking players that match, the ones past the list, and seats held | | in the SDK's `RoomList` `playingPlayerCount`, `playingRoomCount`, `listedClosedRoomCount`, `listedJoinableRoomCount`, `matchingOpenRoomCount`, `moreOpenRoomCount`; `heldSeatCount`; a region's `regionName`. Zaisma's own code keeps `playing`, `joinableRoomCount`, `openRoomCount` |
| The game page's room list, a page at a time (zaisma.com's own, not a developer call): where a page starts and how many rooms it holds, the order it's in, and how many rows a refresh keeps (full rooms always show, last) | `GET /g/<slug>/rooms?cursor=` (the page's `nextCursor`, as an opaque string; a Load more link carries it), `room_order` (`best_to_join`, `most_players`, `fewest_players`) and `shown_row_count`; an old link's `is_hiding_full_rooms` is let go | `listRoomPage(database, gameId, { cursor, pageRoomCount })` answers a `RoomPage` (a `RoomList` and `nextCursor`, `null` on the last page); `roomOrder` (`RoomOrder`, from `ROOM_ORDERS`) and `isHidingFullRooms` on the `RoomPage`; `MAXIMUM_PAGE_ROOM_COUNT` |
| A part of the world rooms run in: a continent code, like `EU` | | `region` (`Region`: `AF`, `AN`, `AS`, `EU`, `NA`, `OC`, `SA`), error `code` `bad_region` |
| What of Zaisma's covers the game on its page: one of its sheets, one of its cards, or nothing | | `Zaisma.page.coveredBy` (`CoveredBy`: `sheet`, `card`, `null`) and its `coveredBy` event; the page's message `zaisma:covered` with `coveredBy`. Inside: `zaismaLayers.coveredBy` |
| How a notice or card waits its turn over a page or a game | | `noticeUrgency`: `information`, `ask`, `urgent` (component option and `data-notice-urgency`); `sheetsToClose` (sheet IDs an urgent card closes); `zaismaLayers` `say`, `show`, `leave`, `step`, `openSheets`; `STALE_INFORMATION_MS`, `MAXIMUM_PAGE_NOTICE_COUNT`, `NOTICE_STAY_MS`, `NOTICE_UNDO_STAY_MS`; a sheet's `SheetStep` (`stepName`) and `SheetTab` (`tabValue`) |
| Where a room's socket stands | | `connectionStatus`: `connecting`, `open`, `reconnecting`, `closed`; whether the player is in the match is `room.awayReason` (`idle`, `hidden` or `null`) |
| Errors a room's player gets, renamed for v1 | | `room_full`, `room_closed`, `room_not_running`, `spectators_full`, `bad_origin`, `already_playing`; for a call, `zaisma_rooms_not_used` (the game doesn't use Zaisma rooms) |
| Keeping a kicked player out, as asked and as told | | `keepOut` (asked), `isKeptOut` (told) |
| A player's cloud save, what it holds, and who made it as it is | `local_storage_items` (each localStorage key and its text), `indexeddb_databases`, `keys` (some localStorage keys asked for) and `missing_keys`; `changed_by_kind`: `player`, `developer` | |
| An earlier version of a save, why it was kept, and the one a change kept | `save_copy_id`; `saved_at`, `copy_reason`: `hourly`, `account_lost`, `smaller`, `restore`, `device_lost`, `developer`; `is_current_save`; `save_copy_count`; `kept_save_copy_id` | `Zaisma.saves.listCopies()` answers `{ saveCopies }`, each `SaveCopy` with `copyReason` (`SaveCopyReason`, the same values) |
| Which format a stored save is in | `save_format_version_number` (`1`), the first key of the save's stored text | |
| When a save or an earlier version was last saved or changed (never `updated_at`) | `saved_at` | `savedAt` on a `SaveCopy` and on `developerChange`'s `DeveloperChange` |
| The game version that saved a save or an earlier version (a label, `null` when the developer wrote it) | `version_id` on a save and a save copy | `versionId` on a `SaveCopy` |
| Whose progress won when two devices' progress differed | | `winnerKind` on `conflict`'s `SaveConflict`: `this_device`, `account` |
| A game's own SQLite database, a statement for it and the values for its `?`s | `sql`, `values` (a blob as `{ blob_base64 }`), `statements`; answered as `rows`, `statement_results` (one per statement) and `read_row_count`, `written_row_count`; its `tables` and `indexes` (`table_name`) | `room.database`: `query(sql, values)` answers rows, `batch(statements)` runs `{ sql, values }` statements in one transaction; a `DatabaseError` has a `code` and a `fix` |
| Erasing a player from a game's database, and whether Zaisma does it when they delete their account | `erase_player`, `erased_tables` (`table_name`, `erased_row_count`); `deleted_account_erase_enabled` | `database.erasePlayer(playerId)` answers `[{ tableName, erasedRowCount }]` |
| A game database's whole contents as SQLite's SQL dump, in parts | `dump_sql` (one part, in and out), `next_cursor` and `cursor` between parts; an import answers `statement_count` and `skipped_statement_count` | `dumpPart(read, cursor)` answers `{ dumpSql, nextCursor, readRowCount }`; `importStatements(dumpSql)` (`DUMP_LIMITS`: `exportPartSizeBytes`, `maximumImportPartSizeBytes`) |
| Going back to an earlier moment of a kept room's world or of every one, and undoing that | `restore_kept_room`, `undo_kept_room_restore`, `list_kept_room_restores`, `restore_every_kept_room`, `undo_every_kept_room_restore`, `get_kept_room_restore_batch`; `restore_to_at`; a restore is `{ id, room_code, restore_to_at, restored_at, undoes_kept_room_restore_id, kept_room_restore_batch_id, undo_expires_at }` (`kept_room_restore_id`), listed as `restores` with `earliest_restore_to_at`; a batch is `kept_room_restore_batch` with `kept_room_count`, `restored_room_count`, `skipped_room_count`, `failed_room_count`, `failed_room_codes`; `live_version_published_since`; errors `no_kept_room_restore`, `no_kept_room_restore_batch`, `kept_room_restore_unavailable`, `kept_room_restore_batch_running` | `server.restoreKeptRoom(roomCode, { restoreToAt })`, `server.undoKeptRoomRestore(roomCode, keptRoomRestoreId)`, `server.listKeptRoomRestores(roomCode)` (`KeptRoomRestore`, `KeptRoomRestoreList`, `earliestRestoreToAt`); `restoreInfo.keptRoomRestore` (`KeptRoomRestoreInfo`, with `erasedPlayerIds`) |
| A deleted kept room's world coming back from its last copy | `bring_back_kept_room`, `is_bringing_back`, `copy_saved_at`; `deleted_kept_rooms` (each `room_code`, `name`, `saved_size_bytes`, `deleted_at`, `bring_back_ends_at`, `bring_back_started_at`, `bring_back_failed_at`), `deleted_kept_room_count`; errors `kept_room_copies_unavailable`, `no_kept_room_copy`, `room_code_in_use`, `game_storage_full` | |
| Going back to an earlier moment of a game's database, and undoing that | `restore_database`, `restore_to_at`; a restore is `{ id, restore_to_at, restored_at, undoes_database_restore_id, undo_expires_at }` (`database_restore_id`), listed as `restores`; `undo_database_restore`; `erased_again_player_count`; errors `no_database_restore`, `database_restore_unavailable` | |
| A game database's use this month, and the most a game can keep | `database_use_this_month`: `read_row_count`, `written_row_count`, `storage_size_bytes`, `maximum_storage_size_bytes`; at it, `database_full` | `MAXIMUM_DATABASE_SIZE_BYTES`, `MAXIMUM_GAME_STORAGE_SIZE_BYTES` (Zaisma's own code); `database_full`, and `hosting_paused` an hour after the game's hosting paused |
| A request from a game to its own game server outside any room, and what that answers | `request_count` (in a day's `game_server`) | `Zaisma.server.request(request, { serverUrl })` answers the `answer`; the game server's `onRequest(player, request, server)`, with `server.database`; sent to `POST /v1/requests/<slug>` as `{ pass, request }`, answered `{ answer }` |
| A game server's schedules, and one run of one | `schedules` (in stats): `schedule_name`, `cron`, `version_id`, `next_run_at`, `last_run_at`; `scheduled_run_count` (in a day's `game_server`) | `schedules: [{ name, cron }]` (`Schedule`, up to `SCHEDULE_LIMITS.maximumScheduleCount`, cron in UTC); `onSchedule(run, server)` with `run.name`, `run.cron`, `run.scheduledAt` (`ScheduledRun`), and `server.database` |
| A friend request a game offers, sent only once the player says yes on Zaisma's page, and who takes them | the social setting `who_can_send_friend_requests`: `nobody` (Invites only), `played_with` (People I play with: the same room now or within the last hour), `anyone`; in Zaisma's own code `friend_requests` (`sender_account_id`, `recipient_account_id`, `answer`: `accepted`, `turned_down`; `taken_back_at_ms` when its sender took it back, `card_sent_at_ms` for one corner card a day per pair, `is_held` when it never reached its recipient) and `room_visits`; a waiting one's `can_show_card`; `takeBackFriendRequest` answers `{ status }`: `taken_back`, `friends` | `Zaisma.friends.sendRequest(playerId)` answers `{ status }`: `sent`, `cancelled`, `already_friends`, `not_taking_requests`; the room's `{ type: "friend_request", playerId }` from a game and `{ type: "friend_request" }` to the other player (look now, never who) |
| A game played off its Zaisma page (exported, on another site, in a store), and its players on the developer's own server | | `Zaisma.setUpOffZaisma({ gameSlug, playerToken })` answers `{ isOffZaisma }` (refused with `bad_game_slug`, `bad_player_token`); `playerToken`, a player's proof from somewhere other than Zaisma (a Sign in with Zaisma ID token or the game's own token, up to 8 KB; `null` for a guest), sent in a hello or request in place of `pass` (`REQUEST_LIMITS.maximumPlayerTokenSizeBytes`); the player's `kind` `outside_zaisma`; `startServer`'s `identifyPlayer(playerToken, { origin })` answering `{ id, name }` or null (`IdentifyPlayer`, `OutsidePlayer`) and `outsideGuestsEnabled`; `signInWithZaismaPlayers({ signInAppIds, siteUrl, loadKeys, loadProfile })` and `guestPlayer()`; refused with `bad_player_token`; `checkChat`'s `null` passes. Inside: `OUTSIDE_PLAYER_LIMITS`, `OUTSIDE_ZAISMA_CHAT_SETTINGS`, `checkedOutsidePlayer`, `isPlayerToken`, `ChatMessage.hasOutsideReceiver` |
| A game's own servers that players' browsers connect to, named in the game's menu and in the warning before play | `own_server_urls` (each `wss://` or `https://` and a host, like `wss://play.example.com`). Inside: `ownServerHostsOf`, `playsOnOwnServers`, the page's `has_own_servers`, `ownServerSheet`; `games.lists_held_at_ms` (a report holding such a game out of Zaisma's lists until a person decides) | `serverUrl` in `Zaisma.joinRoom` and `Zaisma.friends.setRoom` |
| A new developer's listed game waiting for Zaisma's own lists (home, browsing, search) | `is_waiting_for_zaisma_lists` on a game, and where it stands, `zaisma_lists_wait`: `{ is_held_by_reports, progress }`, `progress` `{ live_duration_days, minimum_live_duration_days, counted_player_count, minimum_counted_player_count, quiet_duration_days, minimum_quiet_duration_days }`. Inside: `games.lists_opened_at_ms` (when they opened; they stay open), `LISTS_WAIT_LIMITS`, `listsWaitProgress`, `hasEarnedLists`, `owners.is_invited_developer` (let publish before publishing opened to every account: established from the start) | |
| What watches games after publishing, and flags one for a person | reports of reason `watcher_flag` with `watcher_kind` (`server_time_past_players`, `devices_running_hot`, `plays_without_people`, and on accounts `adult_meets_teens_in_small_rooms`, `adult_gives_teens_items_alone`, `repeated_age_reports`, whose flag names the account as its player); `read_game_file` in the admin MCP. Inside: `WATCHERS`, `WATCHER_LIMITS`, `flagAgainAfterDays`; adults and under-18s in small rooms together in `teen_small_room_meetings` (`met_date`, `is_alone_together`, `alone_together_updated_at_ms`, `teen_item_grant_count`; `TEEN_MEETING_LIMITS`, `recordTeenMeetings`, `endAloneTogether`, `countTeenItemGrant`); per game and day `pressure_measured_duration_sec`, `pressure_serious_duration_sec`, `pressure_play_count` (the game frame's `zaisma:pressure` message, `{ measured_sec, serious_sec }`), and a ticket's own `pressure_measured_duration_sec` | |
| The fixed checks that decide every version | each check's `code` (a `REVIEW_CODES` entry); `stopped_by` in a test-set case (a refusing code, `sandbox`, `reports` or `watchers`). Inside: `FIXED_CHECKS`, `runFixedChecks`, `REFUSING_CHECK_CODES` | |
| The hosts a game's own game server can call (game server reach), and how a call it can't make fails | `game_server_allowed_hosts` (host names, or `*.example.com` for the names under one) | plain `fetch()`; a refused call throws an `OutsideCallError` with a `code` (`OutsideCallErrorCode`: `not_https`, `unreachable_host`, `host_not_allowed`, `outside_call_limit`, `too_big`, `outside_call_timeout`, `outside_call_failed`) and a `fix` (`OUTSIDE_CALL_LIMITS`: `maximumBodySizeBytes`, `timeoutSec`, `maximumCallsPerMin`) |
| A game listed from another site: where it plays, its check, who it opens for, and the report that its site is harmful | `link_out_url`, `link_out_who_can_open` (`everyone`, `waiting_for_standing`, `nobody`), `link_out_review_reason`; errors `bad_link_out_url`, `link_out_not_browser`, `game_hosted_here`, `hosted_only_setting`; the report reason `harmful_site`. Zaisma's own code: `games.link_out_checked_at_ms`, `LINK_OUT_TRUSTED_DOMAINS`, `checkLinkOutUrl`, `linkOutAudience`, `isOpenListing`, `HAS_SOMETHING_TO_PLAY_SQL` | |
| A game's registered links: the name the game opens one by, its address, whether its game page shows it, and who it opens for | `links`, each `{ link_name, destination_url, is_on_game_page, who_can_open, review_reason }`; `who_can_open`: `everyone`, `signed_in_adults`, `waiting_for_standing`, `nobody` | `Zaisma.links.open(linkName, { path, queryParameters, ownSiteUrl })` answers a `LinkStatus`: `opened`, `stayed`; errors `unknown_link`, `bad_link_path`, `bad_link_query`, `bad_own_site_url`, `needs_player_tap` |
| A game's secrets: a name like an environment variable's, its text, and when it was set | `secret_name`, `secret_value` in; a secret is `{ name, set_at }` out, never its value; `deleted_secret_name` | `server.secrets` and `room.secrets` (by name, read-only); on your own server, the environment variables |
| A game server's data files: any file in `zaisma-server/` that isn't code, read whole, and what a game server can be and use | | `room.readDataFile(path)` and `server.readDataFile(path)` (the path from `zaisma-server/`, an `ArrayBuffer` back); `dataFolder` (`startServer`) and `--data-folder` on your own server; `GAME_SERVER_LIMITS` `{ maximumSizeBytes, maximumFileCount, maximumCallCpuDurationMs, maximumStartCpuDurationMs, maximumLoadCpuDurationMs, maximumMemorySizeBytes }`; `SERVER_CODE_FILE` (Zaisma's own code) |
| Something a game sells or grants | `items`, each `{ item_name, title, description, item_kind, item_category, price_minor_units, currency_code, local_prices, card_fee_note, created_at, updated_at }`; `item_kind` `permanent`, `consumable`; `item_category` `cosmetic`, `gameplay`, `content`, `currency`; `price_minor_units` `null` for an item only granted or no longer sold (then `currency_code` `null` too); `local_prices`, each `{ currency_code, price_minor_units }`, never the main currency again; `currency_code` lowercase ISO 4217 as Stripe writes it (`usd`, `brl`); `removed_item_name`; `is_on_game_page` (the game page sells it under Add-ons too); errors `no_item`, `too_many_items`, `bad_item`, `unsupported_currency`, `price_too_low`, `item_has_owners` | `ITEM_LIMITS`, `ITEM_KINDS`, `ITEM_CATEGORIES`, `CURRENCY_MINIMUM_PRICES`, `COUNTRY_CURRENCIES`, `priceFor`, `priceText`, `cardFeeNote`, `checkItem`; `Zaisma.items.list()` answers `ItemForSale` `{ itemName, title, description, itemKind, itemCategory, priceMinorUnits, currencyCode, priceText, isOwned }` |
| A player's purchase or grant of an item, and its proof | `purchase` `{ id, item_name, item_kind, item_count, purchase_source, purchase_status, player_id, game_account_id, paid_minor_units, currency_code, refunded_minor_units, purchased_at, refunded_at, receipt }`; `paid_minor_units` what the whole purchase paid, never the item's `price_minor_units`; `purchase_source` `sale`, `grant`; `purchase_status` `pending`, `completed`, `failed`, `refunded`, `charged_back`; `item_count` how many of the item (1 for a permanent one); `receipt` the signed token; `game_account_id` the game's own ID for the player's account in its own system, given back as sent (not a Zaisma ID, so it says no kind); `is_already_owned`; `owned_item_names`, in the pass too; key area `purchase_access`; errors `no_purchase`, `bad_item_count`, `bad_game_account_id`, `bad_purchase_source`, `bad_purchase_status`, `already_refunded`, `stripe_not_connected`, `receipts_unavailable` | `ReceiptClaims` with `receipt_version_number`, `purchase_id` (and `jti`, the same), `purchased_at`, `purchase_status`, `paid_minor_units`; header `typ` `receipt+jwt`; `ReceiptError`, `ReceiptErrorCode` (`wrong_version` beside the pass codes); `verifyReceipt`, `room.verifyReceipt(receipt)`, `server.verifyReceipt(receipt)`, `RECEIPT_TOKEN_TYPE`, `RECEIPT_VERSION_NUMBER`, `ReceiptCheckBinding`, `RECEIPT_SIGNING_KEY`, `RETIRED_RECEIPT_PUBLIC_KEYS`; columns `deleted_game_slug`, `deleted_game_title` on purchases; `ReceiptSigningService`, `receiptClaimsFor`, `ownedItemNames`, `owningPurchaseOf`, `newGrant`, `recordGrant`, `takeBack`; `player.ownedItemNames` on the game server; `Zaisma.items.owns(itemName)`, `Zaisma.items.owned()` |
| A game that sells itself once, and its demo | `full_game_item_name` (the permanent content item a player owns to play; `null`: free to play), `demo_game_slug` (another of the developer's games, free to play; `demo_game_id` in the games table); Browse's `?price=` one of `free`, `under_5`, `5_to_15`, `15_to_30`, `30_and_up`; errors `bad_full_game_item`, `full_game_item_in_use`, `bad_demo_game`, `account_requirement_locked`, `full_game_not_owned` | `PRICE_RANGES`, `PriceRange`, `priceRangeOf`, `fullGameOwner`, `settlePaidGame` |
| What a game page says the game sells | `purchase_label` `{ categories, has_own_payments }`; `own_payment_categories` (what the developer sells through their own payments, the same four categories); `refund_policy` `no_refunds`, `unused_within_14_days`, `within_14_days`, `own_words`, with `refund_policy_text`; errors `refund_policy_needed`, `bad_refund_policy`, `bad_refund_policy_text`, `bad_own_payment_categories`; content rule `purchases`, findings `ai_paid_random_rewards`, `ai_coin_price_without_real_price` | `REFUND_POLICIES`, `purchaseLabelOf`, `checkPurchaseSettings` |
| Where a game's purchases are delivered, each exactly once | `purchase_delivery` (`game`, `game_server`, `own_server`; `game` by default), in the purchase settings beside `refund_policy`; errors `bad_purchase_delivery`, `no_game_server` | `config.purchaseDelivery` (`"game"`, `"game_server"`, `"own_server"`, given to the SDK by the page); `startServer({ zaismaKey })`, and `ZAISMA_KEY` on your own server for `onPurchase` and `onRefund` |
| Whether a purchase, and its refund, reached the game, its game server or your own server | `handled_at` and `refund_handled_at` on a `purchase` (ISO time, `null` until then); `unhandled_purchases` (completed purchases not handled, and refunded or charged-back ones handled but not yet told, oldest first, at most 50 purchases and 50 refunds) in `get_player_items`; `mark_purchase_handled` (`POST …/purchases/:purchase_id/handled`); webhook events `purchase_completed` and `purchase_refunded` with `purchase` (`null` in every other event); errors `already_handled`, `handled_by_server` | `Zaisma.items.unhandled()` answers `Purchase[]` `{ id, itemName, itemKind, itemCount, purchaseSource, purchaseStatus, gameAccountId, paidMinorUnits, currencyCode, purchasedAt, refundedAt, receipt }`; `Zaisma.items.markHandled(purchaseId)`, errors `bad_purchase_id`, `no_purchase`, `already_handled`, `handled_by_server`, `slow_down` |
| A purchase, or its refund, arriving at the game or its game server | | `Zaisma.items.on("purchase", listener)` and `Zaisma.items.on("refund", listener)` (`ItemsEvents`, `off` to stop), each listener gets a `Purchase`; `onPurchase(state, player, room, purchase)` and `onRefund(state, player, room, purchase)` on the game server (`Purchase`, `PurchaseHandling`, `purchaseHandling` on a `Transport`); the room message `{ type: "zaisma:purchase", purchaseId, receipt? }` the SDK sends to a game server's rooms after a purchase |
| What a request to a game server can fail with | | `RequestErrorCode`: `bad_request`, `too_big`, `bad_pass`, `bad_player_token`, `account_needed`, `game_not_open_to_player`, `game_unavailable`, `no_request_handler`, `game_server_error`, `hosting_paused`, `rented_share_used`, `slow_down`, `bad_origin`, `busy` |
| A shared building block a game is made from, what it states about itself, its kind and the standard it's built on ([`docs/PIECES.md`](PIECES.md)) | in a `piece.json` (a piece's statement) and the upload command's answers: `statement_version_number`, `name`, `kind` (`foundation`, `extension`, `game_system`, `template`, `pack`, `preset`, `skill`, `tool`), `standard` (a name on npm), `summary`, `license`, `entry_path`, `server_entry_path`, `file_paths`, `server_file_paths`; where a game imports it from: `import_path`, `server_import_path`, `import_map`; a game's `standards` and `new_standards`; errors `bad_piece_statement`, `piece_statement_newer`, `bad_piece_source`, `piece_not_found`, `piece_source_unreachable`, `piece_already_added`, `piece_not_added`, `template_file_exists` | |
| A piece's version, apart from a game's (`version_id`), and a library's that isn't a piece | `piece_version`, `library_version` (semver, like `1.0.0`); `earlier_piece_version` and `earlier_library_version` on an update; `newest_piece_version`, `newest_accepted_piece_version`, `newest_library_version`, `newest_accepted_library_version` and `held_back_by_names` from `pieces newer`; errors `piece_source_needed`, `piece_not_updatable`, `piece_not_removable` | |
| What a piece needs and the versions it accepts | `needs`, each `{ name, version_range, kind }`, `kind` one of `piece`, `library`, `engine`; an answer's `kept_names` (left as they are), `engine_needs` (each `{ name, version_range, needed_by_name }`) and `no_longer_needed_names`; errors `piece_version_clash`, `piece_need_unmet`, `piece_still_needed` | |
| A piece's settings and hooks: everything a game changes it through | `settings`, each `{ name, value_kind, default_value, minimum_number, maximum_number, maximum_character_count, choices, summary }`, `value_kind` one of `number`, `integer`, `boolean`, `choice`, `text`, `color`, and `default_value` of the type `value_kind` names; `hooks`, each `{ name, hook_kind, summary }`, `hook_kind` one of `event`, `decision` | `@zaisma/piece`: `openPiece`, `openSettings`, `openHooks`; a piece's `settings` (`get`, `set`, `reset`, `values`, `list`, `onChange` with `{ name, newValue, earlierValue }`) and `hooks` (`on`, `off`, `list`), each name in camelCase (`jump_height_m` is `jumpHeightM`); the piece's own `tell`, `ask` and `refuse`; `PieceError` (`pieceName`, `code`, `field`, `fix`), its codes `unknown_setting`, `bad_setting`, `unknown_hook`, `bad_hook`, `wrong_hook_kind` |
| Where a game's piece came from, whether its files are as they were added, and the game's record of its pieces | `source_kind` (`folder`, `tarball`, `npm`, `marketplace` for Zaisma's), `files_sha256`, `is_edited`, `is_dry_run`; `pieces/pieces.json`: `record_version_number`, `pieces` (each `{ statement, source_kind, files_sha256 }`), `libraries`; errors `piece_edited`, `bad_pieces_record`, `pieces_record_newer` | |
| A maker's check of a piece before publishing it | `is_ready`, `contents_kind`, `problems`, each `{ code, problem_kind, message, path, fix }`, `problem_kind` `refused` or `note`; codes `bad_piece_statement`, `piece_statement_newer`, `missing_file`, `stale_statement_module`, `package_disagrees`, `unlisted_import`, `undeclared_need`, `forbidden_file`, `file_mislabeled`, `skill_file_not_text`, `contains_code`, `file_not_uploadable`, `no_reference`, `no_readme` | |
| A piece on the developer marketplace, and who can find and fetch it ([`docs/DEVELOPER-API.md`](DEVELOPER-API.md#the-developer-marketplace)) | `piece`, named by `piece_name` in calls (its statement's `name`); `visibility` (`private`, `unlisted`, `listed`); `review_status`; `maker_username`; `listing_url`; `get_command`; `test_game_slug`, `source_url`; `is_yours`; error `no_piece` | `package`, `asset`, `listing_id`, `author`, `owner_name`, `public` |
| What Zaisma's checks made of a piece's version, and a pack's or preset's mark | `scan_status` (as a game's version), `findings`, each `{ severity, code, message, path, fix }`; `contents_kind` (`files_only`, `contains_code`); `file_changes`, with `earlier_piece_version`, `added_paths`, `changed_paths`, `removed_paths` | `safe`, `verified`, `has_code`, `diff` |
| Whether a piece was run against what it needs | `fit_status` (`not_tested`, `fits`, `breaks`), with `newest_accepted_piece_version`; `built_on_piece_count` for a standard | `compatible`, `works_with`, `tested` |
| Whether a key's holder may fetch other developers' pieces, and a developer's answer on one | `piece_fetch_mode` on a key (`none`, `ask`, `free`); `your_fetch_status` (`allowed`, `approval_needed`, `declined`, `off`); errors `piece_fetch_off`, `piece_approval_needed` (with `confirm_url`), `piece_fetch_declined` | `can_download`, `download_permission`, `auto_download` |
| A piece's listing's own pictures | `cover_image` (one, or `null`) and `images` on a piece, each `{ id, kind, image_url, width_px, height_px, size_bytes, sha256 }` with `kind` `cover` or `gallery_picture`, as a game's; the command's `listing_pictures`, each with `picture_status` (`sent`, `kept`, `removed`, `refused`) | `thumbnail`, `screenshots`, `cover_url`, `listing_images` |
| Looking at a file of a piece before getting it | `preview_kind` on a version's file (`picture`, `sound`, `model`, or `null`) and `preview_url`; a listing's `file_page_index` | `thumbnail_url`, `download_url`, `asset_type`, `page` |
| What a developer thinks of a piece, and telling Zaisma about one | `rating` (`like`, `dislike`), `like_count`, `dislike_count`, `your_rating`; `report_reason`, `details` | `stars`, `score`, `review`, `flag` |
| The shared skeleton (`@zaisma/skeleton`): its bones and its standard animations | a bone's `name` (`hips`, `spine`, `chest`, `neck`, `head`, and `left_` or `right_` `shoulder`, `upper_arm`, `lower_arm`, `hand`, `upper_leg`, `lower_leg`, `foot`), `parent_name`, `rest_position_m`; an animation's `name` (`idle`, `walk`, `run`, `jump`, `fall`, `land`), `is_looping`, `duration_sec`, `speed_m_per_sec`; how a body stands still, `stance`: `hips_height_m`, `foot_across_m`, `foot_forward_m`, `toe_out_deg`; errors `bone_not_found`, `bad_glb` | `STANCE_HIPS_HEIGHT_M`, `STANCE_FOOT_ACROSS_M`, `STANCE_FOOT_FORWARD_M`, `STANCE_TOE_OUT_DEG`, `BONES`, `BONE_NAMES`, `ANIMATIONS`, `ANIMATION_NAMES`, `BONE_MAPS`, `matchBones`, `retargetRotation`, `retargetHipsPosition`, `readGlb`, `readAnimations`; a bone's `parentName`, `restPositionM`; an animation's `isLooping`, `durationSec`, `speedMPerSec` |
| The gait (`@zaisma/skeleton`'s `gait.js`): how a character stands, walks, jogs, runs and takes to the air, worked out from settings for any speed; a movement is how a game says the character is moving | a gait's settings, the walk's and the run's in pairs: `walk_speed_m_per_sec`, `walk_step_length_m`, `walk_ground_share_pct`, `walk_bounce_pct`, `walk_arm_swing_deg`, `walk_lean_deg`, `walk_foot_lift_m`, `walk_heel_strike_deg`, `walk_push_off_deg`, `walk_hips_drop_m`, `walk_hip_turn_deg`, `walk_hip_tilt_deg`, `walk_hip_sway_m`, `walk_shoulder_turn_deg`, `walk_elbow_bend_deg`, `walk_step_width_pct`, the same sixteen as `run_…`, and `head_steady_pct`, `idle_breath_deg`, `idle_sway_deg`; a movement's `speed_m_per_sec`, `is_on_ground`, `rise_speed_m_per_sec`; `movement_name` (`stand`, `walk`, `jog`, `run`, `air`); errors `unknown_setting`, `bad_setting`, `bad_measures` | `GAIT_SETTINGS` (each `{ name, minimum, maximum, about }`), `GAIT_SETTING_NAMES`, `STANDARD_GAIT`, `readGait`, `fastestSpeedMPerSec`, `gaitMeasures` (`offsetsM`, `ankleHeightM`), `STANDARD_MEASURES`, `speedOnLegsMPerSec`, `createMover` (`mover.update(deltaSec, { speedMPerSec, isOnGround, riseSpeedMPerSec })`, `stridePct`, `movementName`), `movingPose` (`speedMPerSec`, `stridePct`, `idlePct`, `dipPct`), `airPose` (`riseSpeedMPerSec`, `splitPct`, `isLeftAhead`, `driftPct`), `jumpPose` (`pushPct`), `landingDipPct`, `gaitTiming` (`cycleDurationSec`, `groundPct`, `runPct`, `movePct`), `cycleDurationSec`, `poseJoints`, `blendPoses` (`blendPct`), `standardAnimationPose`; a rig's measures' `legSizePct`; a pose's `hipsPositionM`, `rotations` |
| The default body (`@zaisma/body`) and what a game changes on it | its settings `skin_color`, `hair_color`, `face_name` (`none`, `face_01` to `face_16`), `face_pop_pct`, `shape_tall_pct`, `shape_small_pct`, `shape_bulky_pct`, `shape_slim_pct`, `shape_big_head_pct`, `cross_fade_duration_sec`, `shadows_enabled`; hooks `animation_started`, `animation_finished`; errors `unknown_argument`, `file_unreachable`, `picture_unreachable`, `unknown_animation`, `bad_movement`, `bad_hair`, `bad_side`, `bad_part`, `part_of_another_standard`, `part_already_added`, `part_not_added`, `bad_paint_layers` | `createBody`, `bindCharacter`; `playMovement({ speedMPerSec, isOnGround, riseSpeedMPerSec }, { crossFadeDurationSec })`, `movementName`, `playAnimation(name, { crossFadeDurationSec, speedPct, isRestarting })`, `addAnimation`, `update`, `addPart`, `removePart`, `setHair`, `setFacePicture`, `setPaintLayers`, `landmarkObject`, `handAttachment`, `standingJointPositionsM`; `BODY_HEIGHT_M`, `BODY_HEIGHT_WITH_HAIR_M`, `FACE_PICTURE_HEIGHT_PCT`, `DEFAULT_HAIR_PART_URL` |
| The character standard: the one body that parts are made to, in metres, facing +Z with +Y up and its left arm along +X | `standard.json`: `vertices_m`, `triangles`, `regions` (each `{ name, first_triangle_index, triangle_count, shows_skin }`), `vertex_bone_names`, `vertex_bone_weights`, `vertex_shell_directions`, `bind_pose` (the pose the body was made in: `joints_m`, `rotations`), `shells` (each `{ name, distance_m, summary, vertex_reaches_m }`), `outline_margins_m`, `shapes` (each `{ name, summary, bone_scales }`), `landmarks` (each `{ name, kind, bone_name, points_m, summary }`, `kind` `point`, `line`, `ring`), `face_frame` (`center_x_m`, `top_y_m`, `width_m`, `height_m`, `brow_share`, `eye_share`, `mouth_share`), `faces`, `skin_color`, `source_to_standard`, `body_height_m`, `height_with_hair_m`; errors `unknown_shape`, `bad_shape_share`, `unknown_shell`, `unknown_landmark` | `bindPointsToBody` (a binding: `triangleIndex`, `shares`, `nearestPointM`, `distanceM`, `regionName`), `skinWeightsFor` (`boneNames`, `weights`), `pointsOnShape`, `pointsInPose` (a pose: `rotations`, `hipsPositionM`), `bodyPoints`, `bodyPointsInPose`, `jointPositions`, `shellPoints`, `distanceFromBodyM`, `fitsShell`, `fitsOutline`, `landmark`; `REGION_NAMES`, `SHELL_NAMES`, `LANDMARK_NAMES`, `SHAPE_NAMES`, `FACE_NAMES` |
| A region of the body (a run of its skin a part can hide), a shell (a layer round the body a part lies on), a landmark (a named point, line or ring on the skin) and a body shape (a way the one body is reshaped, everything on it following) | region names `head`, `neck`, `chest`, `waist`, `hips`, `left_upper_arm` …; shell names `skin`, `under`, `clothes`, `outer`, `armor`; shape names `tall`, `small`, `bulky`, `slim`, `big_head`; landmark names `hairline`, `brow`, `eye_line`, `left_ear`, `neck`, `left_shoulder`, `left_wrist`, `waist`, `left_ankle` … | |
| A part: something made to the character standard that a body wears (hair, a hat, a jacket), and its statement | `part.json`: `part_statement_version_number`, `name`, `part_kind` (`hair`, `hat`, `face_wear`, `top`, `bottom`, `shoes`, `gloves`, `armor`, `accessory`), `standard`, `summary`, `model_path`, `attach_kind` (`bone`, `skin`), `attach_bone_name`, `shell_name`, `hidden_region_names`, `color_kind` (`hair`, `own`); errors `bad_part_statement`, `part_statement_newer` | `readPart`, `PART_KINDS`, `ATTACH_KINDS`, `COLOR_KINDS` |
| Physics (`@zaisma/physics`): a world of bodies and characters, its feel, and how it's shared through a room as a world on the online core | a world's `bodies`, `body_kinds` (by name, each `mass_kg`, `bounce_pct`, `grip_pct`, `can_be_grabbed`, `shapes`), `character` (`height_m`, `radius_m`), `player_character_mode` (`on_join`, `by_game`), `start_positions_m`, `fall_out_height_m`; a body's `id`, `body_kind_name`, `motion_kind` (`moving`, `fixed`), `position_m`, `rotation_deg`, `mass_kg`, `bounce_pct`, `grip_pct`, `can_be_grabbed`, `shapes` (each `shape_kind` `box`, `ball`, `capsule`, `cylinder`, `hull`, `mesh`, with `size_m`, `radius_m`, `height_m`, `points_m`, `triangle_indices`); its settings `feel` (`realistic`, `cartoony`, `floppy`), `gravity_pct`, `walk_speed_m_per_sec`, `jump_height_m`, `carry_strength_kg`, `reach_m`, `throw_speed_m_per_sec`; hooks `before_grab`, `before_put_back`, `grabbed`, `released`, `body_hit`; errors `bad_world`, `bad_body`, `bad_input`, `bad_character_id`, `unknown_body`, `unknown_character`, `too_many_bodies`, `too_many_characters`, `not_in_charge`, `engine_not_loaded`, `engine_unreachable` | `definePhysicsWorld`, `loadPhysics`, `createPhysics` (`update(nowMs)`), `physicsKind` (`onServer(state, room)`, its `settings` a room's own); a world in play: `bodyIds`, `bodyDeclaration` (`bodyKindNumber`), `drawnBody`, `applyTo`, `bodyState` (`positionM`, `rotation`, `velocityMPerSec`, `spinRadPerSec`, `isResting`, `holderCharacterIds`), `addBody` (`bodyKindName`), `removeBody`, `setBody`, `pushBody` (`pushMPerSec`), `characterIds`, `setInput` (`moveX`, `moveY`, `viewYawRad`, `liftPct`, `isGrabbing`, `jump`, `throw`), `drawnCharacter` (`facingYawRad`, `speedMPerSec`, `riseSpeedMPerSec`, `isOnGround`, `heldBodyId`, `handPositionM`, `loadPct`), `addCharacter`, `setCharacter`, `isInCharge`, `isReady`, `ownCharacterId`; what its things share on the online core: a body's `velocityX`, `spinX`, `bodyNumber`, `bodyKindNumber`, a character's `airTickCount`, `heldBodyNumber`, `anchorX`, `hasThrown`, `refusedBodyNumber`; `FEEL_NAMES` |
| The character (`@zaisma/character`): a level it walks in, its definition, abilities, what it shares and its camera | a level's `shapes` (`shape_kind` `box` or `mesh`, `position_m`, `size_m`, `rotation_deg`, `points_m`, `triangle_indices`), `start_positions_m`, `fall_out_height_m`; an ability's `name`, `slot_number` (1 to 6), `windup_duration_sec`, `active_duration_sec`, `recovery_duration_sec`, `cooldown_duration_sec`, `movement_speed_pct`, `is_cast_in_air_allowed`, `lunge_speed_m_per_sec`, `is_facing_view`, `animation_name`, `touch_label`, and its `hit` (`shape_kind` `sphere` or `box`, `forward_m`, `up_m`, `radius_m`, `size_m`, `damage_point_count`, `knockback_m_per_sec`, `knock_up_m_per_sec`, `stun_duration_sec`, `maximum_target_count`); the state a character shares (`velocity_x_m_per_sec`, `facing_yaw_rad`, `is_on_ground`, `cast_ability_number`, `cast_tick_count`, `slot1_cooldown_tick_count`, `stun_tick_count`, `health_point_count`, `hit_taken_count`, `walk_speed_pct`, `jump_height_pct`, `skin_color_number`, `hair_color_number`, `face_number`, `hair_number`, `outfit_number`, `body_base_number`) and its input (`move_x`, `move_y`, `view_yaw_rad`, `is_facing_view`, `is_sprinting`, `jump`, `is_ability_slot1_pressed` to `is_ability_slot6_pressed`); the camera's settings `camera_…`, `first_person_enabled`, `shoulder_lock_mode` (`toggle`, `hold`, `always`, `off`); hooks `before_cast`, `cast_started`, `jumped`, `landed`, `fell_out`, `before_hit`, `hit`, `knocked_out`, `hit_taken`, `hit_landed`, `model_made`; errors `bad_level`, `bad_ability`, `bad_model` | `defineLevel`, `defineCharacter`, `characterKind`, `createSoloCharacters`, `createCharacterView`, `createCharacterCamera`, `characterActions`, `judgeHits`, `dressCharacter`, `lookFields` |
| Input for every device (`@zaisma/input`): the kinds of device, a game's actions and what they're bound to | `device_kind` (`keyboard_mouse`, `touch`, `gamepad`); its settings `input_enabled`, `mouse_look_mode` (`pointer_lock`, `hold_button`, `off`), `mouse_look_button`, `mouse_look_rad_per_px`, `raw_mouse_enabled`, `invert_look_y_enabled`, `touch_controls_enabled`, `touch_stick_radius_px`, `touch_stick_dead_zone_pct`, `touch_stick_follows_enabled`, `touch_stick_zone_pct`, `touch_look_rad_per_px`, `touch_button_size_px`, `gamepad_move_dead_zone_pct`, `gamepad_look_dead_zone_pct`, `gamepad_look_rad_per_sec`, `gamepad_fine_aim_pct`, `gamepad_trigger_press_pct`, `gamepad_sticks_swapped_enabled`, `gamepad_label_style` (`auto`, `xbox`, `playstation`, `nintendo`), `rumble_enabled`; hooks `device_changed`, `action_pressed`, `action_released`, `pointer_lock_changed`, `before_move`, `before_look`; errors `unknown_action`, `unknown_argument`, `bad_argument`, `bad_binding`, `unknown_control`, `no_page` | `createInput`; `input.move`, `input.lookRad`, `isHeld`, `wasPressed`, `wasReleased`, `pressedPctOf`, `bindings` (each a `Binding`: `keys`, `mouseButtons`, `gamepadButtons`, `touchLabel`), `setBinding`, `setBindings`, `resetBindings`, `captureBinding` (answers `{ actionName, controlKind, controlName }`, `controlKind` `key`, `mouse_button`, `gamepad_button`), `labelsOf`, `setTouchHeld`, `rumble({ strongPct, weakPct, durationMs })`, `snapshot()` (`moveX`, `moveY`, `lookXRad`, `lookYRad`, `heldActionNames`); `MOVE_ACTION_NAMES` (`moveForward`, `moveBack`, `moveLeft`, `moveRight`), `GAMEPAD_BUTTON_NAMES` (by place: `face_bottom` …), `MOUSE_BUTTON_NAMES` |
| What an error or a review reason is, and its other parts | `code`; `message`, `field`, `fix`, `retry_after_sec` (inside `error` only); `content_rule` (inside `review_reason` and `findings` only) | `code` (on the error only) |
## Adding a field, option or tool
1. Look in the glossary. If the concept is there, use its name.
2. Name it by its shape: what it's about, the kind of value, the unit.
3. One type, one unit, and the same keys every time.
4. Describe it in the schema, with limits.
5. Add examples if a call could go wrong, good and bad, as many as it needs.
6. Errors get a code, a field and a fix; changes answer with `next_steps`.
7. Update the glossary, `docs/DEVELOPER-API.md` and the SDK's types (`packages/sdk/zaisma.d.ts`, its reference) in the same change.
8. After the beta, renaming or removing a field, option or tool follows "What's live keeps working" in `docs/DECISIONS.md`.
references/phones.md
CodeCopied
# Phones and touch
Open this when the game should play on phones or tablets. Set what it supports with `update_game`: `devices` (`phone`, `tablet`, `computer`), `controls` (`touch`, `keyboard_mouse`, `gamepad`) and `screen_orientation` (`portrait`, `landscape`, `either`). Zaisma's pages tell players what it supports.
## Touch
- **Use pointer events** (`pointerdown`, `pointermove`, `pointerup`) rather than mouse events alone: one code path for mouse, touch and pen.
- **Draw controls on screen** for a touch player: a stick, buttons, or tap and drag. Make each one big enough for a thumb, about 48 CSS pixels at least, and away from the screen's edges, where phones take swipes for themselves.
- **No hover.** Nothing a touch player needs should appear only on hover.
- **Stop the page from moving.** Set `touch-action: none` on the game's canvas, so a drag plays the game instead of scrolling or zooming the page.
- **Multi-touch.** Track each pointer by its `pointerId`, so a thumb on the stick and a thumb on fire both work.
## Screen sizes
- **From 320 by 667 up.** A small phone in portrait is 320 CSS pixels wide; the game should fit and stay usable there, and up to a 4K monitor.
- **Size to the space, not the screen.** The game runs in a frame on its Zaisma page, so size the canvas to `window.innerWidth` and `window.innerHeight` and redraw on `resize`.
- **Sharp on dense screens.** Size the canvas's drawing buffer by `devicePixelRatio`, capped at 2 or 3 for big 3D games, where a full-density buffer costs too much.
- **Text that reads.** At least about 14 CSS pixels for anything the player must read.
## Orientation
Pick the one the game plays best in, and set `screen_orientation`. A landscape game on a phone held upright should say "Turn your phone" rather than draw tiny: check `window.innerWidth > window.innerHeight` on `resize`.
## Hidden and covered
- **Pause when hidden.** A player who switches apps or tabs comes back to the same moment: pause on `visibilitychange` when `document.hidden`, and mute the audio. In a real-time room, a game hidden for 2 minutes counts as away.
- **Covered by Zaisma.** `Zaisma.page.coveredBy` (and its `coveredBy` event) says when the buy sheet or a card covers the game; pause input then.
- **Audio after a tap.** Phones start audio only after the player touches the screen: start it on the first `pointerdown`.
## Performance
A mid-range phone has a fraction of a PC's graphics power and memory. Offer lower settings, or pick them from the screen's size; keep textures compressed (`loading.md`); and test on a real phone, or at least the browser's phone emulation at 320 by 667.
references/pieces.md
CodeCopied
<!-- Made by scripts/build-skill.mjs: never edit it by hand. -->
# Pieces
A piece is a shared building block a game is made from or with: a body that already walks, input for every device, save and load, a sky, online play, a pack of footsteps, a skill for the AI that builds the game. A game adds the pieces it wants and spends its effort on what makes it its own. Every piece is optional, and no game is locked into any of them.
Pieces are open. Anyone publishes one, for any engine or kind of game. Zaisma's own are added, updated and checked exactly as a stranger's are: nothing in the command knows any piece, standard or publisher by name. Zaisma's are MIT licensed, in [`pieces/`](https://github.com/zaisma/zaisma-sdk/blob/main/pieces).
This page is the frame every piece stands on: what a piece states about itself, how it's added to a game, how its versions move, how its settings and hooks are opened, and how one is published to [Zaisma's marketplace](#the-marketplace), where developers share and rate them.
## The kinds
A kind is how a piece arrives and what it may hold, never only a label.
| Kind | What it is | How it arrives |
| --- | --- | --- |
| `foundation` | A standard everything else fits: a skeleton, a body, input, save and load, lighting, a networking core. | Added to a game, and moved by version. |
| `extension` | Plugs into one foundation: a kind of sync, a camera style, a way to move, an ability. | Added to a game, and moved by version. |
| `game_system` | A genre's part: a round timer, a combo counter, an inventory. | Added to a game, and moved by version. |
| `template` | A genre's systems wired together, with no style of their own. | Copied into a game once, and then the game's own. |
| `pack` | Images, models and sounds, as a folder in its maker's own structure. | Added to a game, and moved by version. |
| `preset` | Values for another piece or a tool: a way to move, a look, a mix. | Added to a game, and moved by version. |
| `skill` | Instructions for a developer's AI. Always under an open licence, text all through, and read in full before anyone gets it. | Fetched for the AI (`pieces get`); a game never holds one. |
| `tool` | Something a developer runs on their own computer. Open or closed source, as its maker chooses. | Fetched to the developer's computer (`pieces get`); a game never holds one. |
The first four are the layers a game's own code is built from: each is built on a standard, and all but a template open settings and hooks. What people call a module is an extension or a game system.
## Standards
Every foundation, extension, game system and template names the **standard** it's built on, so pieces made to fit one set of foundations are never mistaken for pieces made to fit another. A pack, preset, skill or tool names one when it's made for one (a model pack rigged to a skeleton), and gives `null` when it fits anywhere. A standard is whatever its keeper says it is: a set of foundations for three.js, a base for Godot, a skeleton alone.
A standard's name is a name on npm, like `@studio/standard`. Two makers' standards can never share a name, and whoever holds the name on npm keeps the standard. A piece built on someone else's standard names it the same way; a small standard can be one piece, named after itself. Zaisma's are in [Zaisma's pieces](#zaismas-pieces): one standard among any that people publish.
Adding a piece built on a standard the game didn't have says so, plainly. Nothing stops it: a game chooses its pieces.
## Adding pieces to a game
```
npx @zaisma/cli pieces add @studio/dash-move # by its name, the newest version
npx @zaisma/cli pieces add @studio/dash-move@^1.2 # or the newest within a range
npx @zaisma/cli pieces add ./my-piece # a piece's folder
npx @zaisma/cli pieces add ./my-piece-1.0.0.tgz # or the .tgz that npm pack makes of it
npx @zaisma/cli pieces add @studio/dash-move --dry-run # what it would bring, changing nothing
npx @zaisma/cli pieces # what the game has
```
Run them in the game's folder (the one with its `index.html`, or its source for a game that's built), or give `--folder`. Each takes `--json`.
**Where a name is looked up.** With `ZAISMA_KEY` set, on [Zaisma's marketplace](#the-marketplace) first, then on npm; with no key, on npm alone. The game's record keeps where each piece came from (`source_kind`), and a later `pieces update` asks the same place. A skill or a tool is never added to a game: `pieces get` fetches it.
A piece's files go in `pieces/<name>/` with its `piece.json`, its game server files (when it has any) in `zaisma-server/pieces/<name>/`, where a game server on Zaisma can import them and players are never served them, and the game's record of its pieces in `pieces/pieces.json`. Commit all three.
**What adding does, always:**
- **What a piece needs is stated, and comes with it.** Every piece states what it needs and which versions it accepts; adding brings what's missing, and says what it brought.
- **Never a second copy.** A piece the game already has, at a version the new piece accepts, is left exactly as it is.
- **Never moved by itself.** A piece changes version only when you run `pieces update` for it.
- **A clash stops everything, plainly.** When the game has a version the new piece doesn't accept, nothing is added, and the error (`piece_version_clash`) says both versions and the two ways out: move the one in the game, or use a version of the new piece that accepts it. Two pieces being added that need versions of the same thing with no overlap stop the same way.
- **A library isn't doubled either.** A piece may need a library that isn't a piece (three.js). A game that has it in its own `package.json` uses its own; one outside the accepted range is a clash like any other. A game without it gets the library's browser files in `pieces/<library>/`, and the command prints the import map its page needs.
- **An engine is stated, never brought.** A piece for an engine that isn't a library on npm (Godot) says which versions it needs; the command says so and leaves the engine to the game.
- **A piece's code is never run.** Adding copies the files a piece lists and nothing else: no install scripts, no links, no path outside the game's folder. A piece from npm is checked against npm's own hash of it first, and one from Zaisma's marketplace file by file against the hashes its version lists.
**Using one:** import it from where it was added, as the command prints:
```js
import { createDash } from "./pieces/@studio/dash-move/index.js";
```
Each piece's `index.d.ts` is its reference, with every call, setting, hook and error explained, and its `README.md` shows it in use. An AI reads those two and never needs the piece's insides. `zaisma pieces --json` answers every piece's settings and hooks too.
**A page with no bundler** needs an import map before its scripts when a piece brought a library, so the pieces find it. `zaisma pieces` prints it:
```html
<script type="importmap">{"imports":{"three":"./pieces/three/build/three.module.js"}}</script>
```
**Uploading:** `zaisma check` and `zaisma upload` leave every `.d.ts` out of what they check and send, since type files never run. Uploading through the MCP's `upload_files`, leave them out the same way.
## Moving a version
```
npx @zaisma/cli pieces newer # what has a newer version where it came from, and what holds it back
npx @zaisma/cli pieces update @studio/dash-move # move one to the newest
npx @zaisma/cli pieces update @studio/dash-move --version "^1.4"
npx @zaisma/cli pieces update @studio/dash-move --from ./dash-move-1.5.0.tgz # one that came from a folder or a .tgz
npx @zaisma/cli pieces update @studio/dash-move --from @studio/dash-move # the same version, now from where it's published
npx @zaisma/cli pieces remove @studio/dash-move
```
- **`pieces newer` looks where each piece came from:** Zaisma's marketplace for one added from there (it needs `ZAISMA_KEY`), npm for one from npm, and each line says which. One added from a folder or a `.tgz` has nowhere to be looked up, and is named as such.
- **A piece added from a folder gets updates once it's moved to where it's published.** `pieces update <name> --from <name>`, at the version the game has, looks the name up on the marketplace (then npm) and checks that its files there are exactly the game's copy. If they are, the record says it comes from there now, and what it brought from a folder (the pieces and libraries it needs, and theirs) moves with it, each checked the same way; one that isn't published at that version, or whose files differ, stays and is named with why. Nothing is written but the record. A piece whose published files differ from the game's copy is refused (`piece_files_differ`); `--discard-edits` takes the published files instead. From then on, `pieces newer` and `pieces update` ask there.
- **A version moves when the game chooses,** one piece at a time: `pieces update` moves the piece named and nothing else. What its new version needs and the game lacks is brought; a piece the game has that it no longer accepts is a clash, with the ways out.
- **Only when everything else accepts it.** If another piece in the game needs a range the new version is outside, nothing moves, and the error names that piece. `pieces newer` shows this before you try: the newest version, the newest the rest of the game accepts, and which pieces hold it back.
- **Removing** takes one piece out, unless another needs it (`piece_still_needed`). What it needed stays: the answer names what no piece needs any more, for you to remove or keep.
- **A template is the game's own** once copied: it has no version to move and nothing to remove, and it no longer holds the versions of the pieces it brought.
## Settings and hooks
**A piece is never edited by a game.** Everything a game would change is a setting or a hook, so the piece can move to a newer version and keep the game's changes. A super jump is a setting turned up while playing. If a game would have to copy a piece to change it, the piece is missing a hook: tell its maker.
Every piece states its settings and hooks in its `piece.json`, so they're read without opening its code:
- A **setting** is a number or an integer with its range, `true` or `false`, one of a few choices, text, or a colour, with a default. Every setting can be changed while playing.
- A **hook** is a point where the piece calls the game's code. An `event` tells the game something happened. A `decision` asks the game before something happens, and what the game answers is what happens.
Pieces written in JavaScript open them the same way, through [`@zaisma/piece`](https://github.com/zaisma/zaisma-sdk/blob/main/pieces/piece): a create call takes `{ settings, hooks }` beside its own arguments and gives back an object with `settings` and `hooks` on it.
```js
const dash = createDash({ settings: { dashSpeedMPerSec: 18 }, hooks: { dashed: () => playWhoosh() } });
dash.settings.set({ dashCooldownSec: 0.2 }); // while playing
dash.settings.get("dashCooldownSec"); // 0.2
dash.settings.list(); // every setting: what it takes, its default, what it is now
dash.hooks.on("beforeDash", (dashDistanceM) => (isSlowed ? dashDistanceM / 2 : dashDistanceM));
```
In code a name is in the language's own style (`dash_speed_m_per_sec` is `dashSpeedMPerSec` in JavaScript). A setting or hook the piece doesn't have is refused, with the ones it does have in the error's `fix`; so is a value outside what a setting takes.
**What a piece keeps.** A piece that has something of the player's to bring back next time (the controls they rebound, how fast they like the view to turn) says so with `kept`, which `@zaisma/piece`'s `openKept` opens from the settings that are the player's own choices and any state of its own. Any save keeps it beside the game's progress and gives it back when the game opens: the game names the piece and handles nothing else.
```js
const save = await openSave({ saveFormatVersionNumber: 1, defaults: { level: 1 }, keptPieces: [input] });
```
A kept setting is kept only once it differs from what the game made the piece with, so a game that changes its own default later still reaches every player who never changed it. What a piece keeps carries its own format number: a record from a newer version of the piece is kept as it is, never read and never lost, and so is one of a piece the game no longer keeps.
`zaisma pieces` marks a piece whose files were changed by hand, and `pieces update` and `pieces remove` refuse to lose the edits until you say `--discard-edits`.
## Zaisma's pieces
| Piece | Kind and standard | Gives | Needs |
| --- | --- | --- | --- |
| `@zaisma/piece` | `foundation`, its own small standard `@zaisma/piece` | How a JavaScript piece opens its settings and hooks, and what it keeps between plays, the same in every piece, in a browser and on a game server. A game never adds it by name: it comes with any piece that needs it. | nothing |
| [`@zaisma/net`](https://github.com/zaisma/zaisma-sdk/blob/main/pieces/net) | `foundation`, on `@zaisma/standard` | The online core: one room carries every kind of sync a game uses, characters, objects, events, turns and worlds of bodies many players act on at once. A piece says what it shares (a character's fields and how it moves a step, a world's things and how they step together), never how; the same game runs on Zaisma's relay, with a game server in Zaisma's rooms, and on that game server on your own machine, changing one word. A player's own moves answer at once and whoever is in charge has the last word, eased in; two players pushing one body meet in the same place on every screen; everyone else's characters are drawn smoothly a moment behind; hits can be judged by what the attacker saw. Characters of up to 256 fields in groups, fields kept to their own player, step events (a shot, a hit) the server reads with what the player saw, and inputs held while they pause. It says nothing while nothing changes, says again what a bad connection lost, rides a stall without widening its delay, and carries on through a drop, a restart or a host that leaves. Version 2.1 adds to 2.0: a game on 2.0 or 1 keeps working and moves when it chooses. | `@zaisma/piece` |
| [`@zaisma/physics`](https://github.com/zaisma/zaisma-sdk/blob/main/pieces/physics) | `foundation`, on `@zaisma/standard` | Physics that works as it's added, alone and online, for every kind of game, on the Rapier engine it ships with: one world of bodies (moving, kinematic or fixed), ground for a big outdoor map read from a data file and laid only where things are, joints, wheeled vehicles with seats, collision layers and queries, and characters that walk by the piece's rules or the game's own (`defineCharacterKind`). Online it's a world on the online core, with nothing for the game to write: a player's own move answers at once and settles to the room's word, everything a replay needs rides along so it never drifts, and a body at rest costs nothing, in bytes or in game server time. Version 2: a game on 1.x keeps working; its party characters are now `@zaisma/physics-party`. | `@zaisma/net`, `@zaisma/piece` |
| [`@zaisma/physics-party`](https://github.com/zaisma/zaisma-sdk/blob/main/pieces/physics-party) | `extension` of physics, `@zaisma/standard` | Party characters for the physics piece: they walk with momentum, push as hard as they're strong, and grab, carry and throw, several on one heavy thing lifting what one can't (each as strong as its character, so two lift what one only tips). How the world behaves is one setting, `feel`: `realistic`, `cartoony` or `floppy`, the loose blend of physics party games. | `@zaisma/physics`, `@zaisma/piece` |
| [`@zaisma/input`](https://github.com/zaisma/zaisma-sdk/blob/main/pieces/input) | `foundation`, `@zaisma/standard` | Input for every device: keyboard and mouse, touch (a stick, a drag to look and a button for each action, drawn for it) and gamepads, read as the actions a game names, where the player moves and how far they turn the view in radians. Prompts as each device names its buttons, a controls screen's rebinding, and rumble. It keeps the player's rebound controls and their own choices among its settings for a save. | `@zaisma/piece` |
| [`@zaisma/save`](https://github.com/zaisma/zaisma-sdk/blob/main/pieces/save) | `foundation`, `@zaisma/standard` | Save and load: a game's progress and what each of its pieces keeps of its own, written shortly after a change and at once as the game closes, older saves upgraded, and never written over when it changed elsewhere. Kept in the browser (on Zaisma it follows a signed-in player to every device) or on the game's own game server, the same on Zaisma's rooms and on your own server, with the later of two devices' progress winning. | `@zaisma/piece` |
| [`@zaisma/lighting`](https://github.com/zaisma/zaisma-sdk/blob/main/pieces/lighting) | `foundation`, `@zaisma/standard` | Lighting and sky for three.js: a sky with sun, moon, stars and clouds, sunlight whose shadows follow the player, fill light, reflections and fog that match it (glowing warm toward a low sun, and pooling low as ground fog), all set by the time of day, which can run on its own. Night stays playable, every colour can be changed while playing, and its quality fits the device, stepping down while frames run slow. The sky's numbers have no engine, for another engine to follow. | `@zaisma/piece`, the library `three` |
| [`@zaisma/lighting-effects`](https://github.com/zaisma/zaisma-sdk/blob/main/pieces/lighting-effects) | `extension` of the lighting, `@zaisma/standard` | Camera effects: bloom on bright things, colour grading with named moods (vivid, warm, cool, faded, moody, noir, dreamy, or a game's own), sun rays, and soft shade in corners on PCs only. Each is off until a game turns it on and has its own level per device; auto levels follow the lighting's quality and drop on slow frames, so a phone keeps its frame rate. | `@zaisma/lighting`, `@zaisma/piece`, the library `three` |
| [`@zaisma/skeleton`](https://github.com/zaisma/zaisma-sdk/blob/main/pieces/skeleton) | `foundation`, its own small standard `@zaisma/skeleton` | The shared skeleton: 19 bones and six standard animations (idle, walk, run, jump, fall, land) that any character on it plays, with no engine, as files any engine loads. Bone maps from Mixamo and VRM names, and the maths that plays the animations on a rig with other rest orientations. With it, the gait that makes the animations (`gait.js`): give it how fast a character moves and it answers the pose, standing, walking, jogging or running, with feet that never slide at any speed or on legs of any length. | nothing |
| [`@zaisma/body`](https://github.com/zaisma/zaisma-sdk/blob/main/pieces/body) | `foundation`, `@zaisma/standard` | The default body on the skeleton, for three.js: a low-poly fighter whose skin and clothes are painted on, with a face laid on its head, its hair as a part, body shapes, and every standard animation; it stands, walks, jogs, runs, jumps and lands by itself from how fast the game says it moves (`playMovement`); or a game's own character on the skeleton, moving the same way on its own legs. With it, the character standard that parts are made to: the body's regions, the shells round it, its landmarks, and a part's statement. | `@zaisma/skeleton`, `@zaisma/piece`, the library `three` |
| [`@zaisma/character`](https://github.com/zaisma/zaisma-sdk/blob/main/pieces/character) | `extension` of the body, `@zaisma/standard` | A third-person character that feels good to play, for three.js: snappy movement with a forgiving jump that walks up steps and stands on ramps, a camera that turns freely, locks over the shoulder and zooms into first person, and abilities that are cast, cool down and hit (health, knockback, a stun). Online on the online core: a player's own moves answer at once, and a hit is judged by the game server by what its attacker saw, or with no server code by the one who was hit. Each character stands on the default body in its own look, or on a game's own on the skeleton. The movement and the camera are written down exactly (`MOVEMENT.md`) for another engine. | `@zaisma/net`, `@zaisma/body`, `@zaisma/input`, `@zaisma/piece`, the library `three` |
Zaisma's foundations are built on the standard `@zaisma/standard`; the skeleton and its animation names are a small standard of their own, `@zaisma/skeleton`, so another maker's standard can build on just that.
### The skeleton, for another engine
`skeleton.json` gives each bone's name, its parent and where its joint rests in metres; `animations.json` each animation's name, whether it loops, its length and the speed that keeps its feet from sliding; `skeleton.glb` holds the bones with the animations as glTF. At rest the body stands in a T-pose facing +Z, +Y up, its left arm along +X, its legs straight down and its feet forward, and every bone's own axes line up with the world's, so a bone's rest rotation is none in any engine. An animation moves the hips and turns the bones, and plays in place: the game moves the character.
### The character standard
Parts (hair, hats, clothes, armor) fit the default body because they're made to one standard that doesn't change under them. It's data, `standard.json` in the body piece, with calls over it in `standard.js` that need no engine; [the body's README](https://github.com/zaisma/zaisma-sdk/blob/main/pieces/body/README.md) and `standard.d.ts` are its reference.
| | What it is |
| --- | --- |
| The skin | The body's points and triangles in metres: facing +Z, +Y up, the left arm along +X, feet on the ground, standing as it was made (its `bind_pose`: arms out, legs slanting out to feet set apart). |
| Regions | Every triangle is in one: `head`, `neck`, `chest`, `waist`, `hips`, and on each side `upper_arm`, `lower_arm`, `hand`, `upper_leg`, `lower_leg`, `foot`. A part names the ones it hides. |
| Shells | The skin pushed out to set distances, layer on layer: `skin`, `under`, `clothes`, `outer`, `armor`. A part names the one it lies on and never pokes under it. |
| Landmarks | Named points, lines and rings on the skin, each moving with a bone: the hairline, brow, eye line, ears, neck, shoulders, wrists, waist, ankles and more. |
| Body shapes | `tall`, `small`, `bulky`, `slim`, `big_head`: each stretches the bones' parts, and everything tied to the bones follows. |
| A part | A folder with a `part.json` (what kind it is, the bone or skin it holds on to, its shell, the regions it hides) and a `.glb` in the standard's space. |
## Making a piece
A piece is a folder with a `piece.json` at its top, its statement: what it is, the standard it's built on, what it needs, and its settings and hooks. The command, and anything else that lists pieces, reads only this.
```json
{
"statement_version_number": 1,
"name": "@studio/dash-move",
"piece_version": "1.0.0",
"kind": "extension",
"standard": "@studio/standard",
"summary": "A dash for the character: a burst of speed with a cooldown.",
"license": "MIT",
"entry_path": "index.js",
"server_entry_path": null,
"file_paths": ["index.js", "index.d.ts", "piece.json.js", "README.md", "LICENSE.txt"],
"server_file_paths": [],
"needs": [
{ "name": "@studio/body", "version_range": "^1.0.0", "kind": "piece" },
{ "name": "@zaisma/piece", "version_range": "^1.0.0", "kind": "piece" },
{ "name": "three", "version_range": ">=0.160.0 <1.0.0", "kind": "library" }
],
"settings": [
{ "name": "dash_speed_m_per_sec", "value_kind": "number", "default_value": 14, "minimum_number": 1, "maximum_number": 60, "maximum_character_count": null, "choices": null, "summary": "How fast a dash moves the character." },
{ "name": "dash_cooldown_sec", "value_kind": "number", "default_value": 1.5, "minimum_number": 0, "maximum_number": 30, "maximum_character_count": null, "choices": null, "summary": "How long before the character can dash again." }
],
"hooks": [
{ "name": "before_dash", "hook_kind": "decision", "summary": "Asked before each dash with its distance in metres; answer another distance to change it, or 0 to stop it." },
{ "name": "dashed", "hook_kind": "event", "summary": "Told when a dash ends." }
]
}
```
### What a piece states
Every field is there every time, and an unknown one is refused, so a typo never passes quietly.
| Field | What it holds |
| --- | --- |
| `statement_version_number` | The format this file is written in: `1`. A command that meets a higher number says to run the newest command instead of guessing. |
| `name` | The piece's name, as npm takes them. |
| `piece_version` | Its version: three numbers, like `1.0.0`. Follow semver: a change that breaks games raises the first number, and Zaisma's marketplace refuses one that takes something away without it ([A version tells the truth](#a-version-tells-the-truth)). |
| `kind` | `foundation`, `extension`, `game_system`, `template`, `pack`, `preset`, `skill` or `tool` ([The kinds](#the-kinds)). |
| `standard` | The standard it's built on, by its name on npm ([Standards](#standards)); `null` only for a pack, preset, skill or tool built on none. |
| `summary` | A sentence or two on what it gives a game, up to 400 characters. |
| `license` | The licence it's under, as SPDX names it: `MIT`, `Apache-2.0`, `CC0-1.0`. A piece whose source is closed gives `UNLICENSED`, or `LicenseRef-<name>` for terms of its maker's own. A skill is always under an open one. |
| `entry_path` | The file to start from: for a layer, the one a game imports (`null` with only game server files); for a skill, `SKILL.md`, the file an AI reads first; for a preset or a tool, its main file or `null`; for a pack, `null`. |
| `server_entry_path` | The file a game server imports; `null` for a piece with no game server files. |
| `file_paths` | Every file a game gets, each by its path inside the piece: forward slashes, nothing hidden (no part starting with a dot) and nothing in `node_modules`. The `piece.json` always comes too and isn't listed. A template's are copied into the game's own folder. |
| `server_file_paths` | Every file a game server gets. A file both sides share is listed in both. Empty for a template, whose game server files are the game's own, under `zaisma-server/` in `file_paths`. |
| `needs` | What it needs: each `{ name, version_range, kind }`. |
| `settings` | Its settings: each `{ name, value_kind, default_value, minimum_number, maximum_number, maximum_character_count, choices, summary }`. Empty for anything but a foundation, an extension or a game system. |
| `hooks` | Its hooks: each `{ name, hook_kind, summary }`. Empty the same way. |
**A need** is `{ name, version_range, kind }`. `version_range` is a semver range like `^1.0.0`, `>=0.160.0 <1.0.0` or `1.x || 2.x`. `kind` says what it is:
| Need `kind` | What it is |
| --- | --- |
| `piece` | Another piece, by its name. Brought when the game lacks it. |
| `library` | A library on npm that isn't a piece. The game's own is used when its `package.json` has one; else its browser files are brought. |
| `engine` | An engine that isn't a library on npm, by its name in lowercase (`godot`). Stated to the developer, never brought or checked. |
**A setting** names what it holds and its unit, in lowercase with underscores ([`docs/NAMING.md`](naming.md)): `jump_height_m`, `shadows_enabled`. Its `value_kind` says what it takes, and the fields that don't apply to that kind are `null`:
| `value_kind` | `default_value` | Also given |
| --- | --- | --- |
| `number` | a number | `minimum_number` and `maximum_number`: every number has a range |
| `integer` | a whole number | `minimum_number` and `maximum_number` |
| `boolean` | `true` or `false` | |
| `choice` | one of `choices` | `choices`: 2 to 50 lowercase words |
| `text` | text | `maximum_character_count` |
| `color` | six hex digits in lowercase, like `"#3fa9f5"` | |
A setting can be changed while playing. What can only be given once, when the piece is made, is an argument of its create call instead, explained in its reference.
**A hook** is `{ name, hook_kind, summary }`, `hook_kind` being `event` (the piece tells the game) or `decision` (the piece asks, and the game's answer is what happens). What a hook is called with is in the piece's reference.
### Its code
What makes a piece good to build on:
- **Files that run as they are,** with no build step. In JavaScript: plain ES modules that import the piece's own files, its needs, and nothing else.
- **Needs imported from where a game has them.** A game holds `@studio/dash-move` at `pieces/@studio/dash-move/`, so from there a piece of the same scope is `../body/index.js`, one of another scope `../../@zaisma/piece/index.js`, and one with no scope `../../round-timer/index.js`. A library is imported by its name (`three`).
- **One statement.** A JavaScript piece reads its own settings and hooks from `./piece.json.js`, the statement as a module, and opens them with `@zaisma/piece` (its [README](https://github.com/zaisma/zaisma-sdk/blob/main/pieces/piece/README.md) shows how). List `piece.json.js` in `file_paths`; `zaisma pieces check <folder> --fix` writes it from `piece.json`, and a piece whose two disagree is refused.
- **An `index.d.ts`** with every call, setting, hook and error explained and an example: it's what an AI reads.
- **Closed inputs and plain errors:** an unknown setting or argument is refused, and every error has a stable `code`, the `field` at fault and a `fix`.
- **Names that say what they hold** ([`docs/NAMING.md`](naming.md)).
- **No file without an extension** in a piece for a game whose folder is uploaded as it is: Zaisma's upload takes none, so a licence travels as `LICENSE.txt`.
### Check and publish
```
npx @zaisma/cli pieces check ./my-piece # before publishing
npx @zaisma/cli pieces check ./my-piece --fix # and write piece.json.js again from piece.json; for a pack, list its folder's files in file_paths
```
The check reads the statement and the files it lists, and runs nothing. It ends with exit code 6 when the piece wouldn't add or would break in a game:
| Problem | Kind | What it found |
| --- | --- | --- |
| `bad_piece_statement` | refused | The piece.json isn't one: the message names the field. |
| `piece_statement_newer` | refused | The piece.json is written for a newer command than this one. |
| `missing_file` | refused | The piece.json lists a file that isn't there, or the file is a link. |
| `stale_statement_module` | refused | piece.json.js isn't piece.json as a module any more; --fix writes it again. |
| `package_disagrees` | refused | The package.json beside it has another name or version, or leaves a listed file out of what npm packs. |
| `unlisted_import` | refused | A file imports a file of the piece's own that the piece.json doesn't list, so a game wouldn't get it. |
| `undeclared_need` | refused | A file imports another piece or a library that isn't in needs. |
| `forbidden_file` | refused | A file is a program for Windows, macOS or Linux, a shell script, an archive or a PDF, which Zaisma's marketplace takes in no piece, as in no game. |
| `file_mislabeled` | refused | A pack's or preset's file isn't what its name says: its bytes are another kind of file. Zaisma's marketplace refuses it. |
| `skill_file_not_text` | refused | A skill's file isn't text: a skill is read in full before anyone gets it. |
| `contains_code` | note | A pack or preset holds a file that can run, can point at a script, or can't be seen through, so the marketplace marks it Contains code, never No code. |
| `file_not_uploadable` | note | A file is of a type Zaisma's upload doesn't take, so a game whose folder is uploaded as it is can't hold the piece. |
| `no_reference` | note | The file a game imports has no .d.ts beside it: it's what an AI reads to use the piece without opening its code. |
| `no_readme` | note | There's no README.md among the piece's files. |
Publish it to [Zaisma's marketplace](#the-marketplace) with `zaisma pieces publish`, to npm with `npm publish` (its `package.json` giving the same name and version as its `piece.json` and packing every file it lists), or both; anyone adds it by name. A piece that's on neither is added from its folder or its `.tgz`.
## The marketplace
Zaisma's marketplace (zaisma.com/marketplace) is where developers publish, share and rate pieces of every kind. It reads a piece's statement and never keeps a second one: what a listing says a piece is, is what its `piece.json` says. Zaisma's own pieces are listed and rated like anyone's.
```
npx @zaisma/cli pieces publish ./my-piece # its own check, its files, then Zaisma's checks
npx @zaisma/cli pieces publish ./my-piece --visibility listed # and put it in the marketplace's lists
npx @zaisma/cli pieces search footsteps --kind pack # find pieces, the best rated first
npx @zaisma/cli pieces get @studio/level-notes # fetch a skill or a tool
```
Each needs `ZAISMA_KEY`. A developer's AI does the same through the MCP: `publish_piece`, `search_pieces`, `get_piece`, `read_piece_file` ([`docs/DEVELOPER-API.md`](DEVELOPER-API.md#the-developer-marketplace)).
- **Private first.** A new piece is `private`: only its maker fetches it, which is all a studio sharing pieces between its own games needs. `unlisted` opens it to anyone who has its name; `listed` puts it in the marketplace's lists.
- **A version never changes.** Raise `piece_version` for the next one. A game moves to it only when it chooses (`pieces update`).
- **Names.** A scope (`@studio`) belongs to the first developer to publish under it on Zaisma; `@zaisma` is Zaisma's own.
- **What a piece needs** shows on its listing from its own statement: each need with the versions it accepts, a link to its own listing, and the newest version there the range accepts. Zaisma says a piece fits a version only when it ran the two together; everything else says Not tested, never a guessed Fits.
- **A test game.** A listing can link one of its maker's games that uses the piece, to try before using it.
- **Pictures of its own.** A listing can carry a cover and a gallery its maker made (see A listing's pictures).
- **Looking before getting.** A listing shows every picture, sound and 3D model inside the piece, to look at, hear and turn (see Looking before getting).
- **Ratings.** A like or a dislike, one per developer, anonymous. Good pieces rise in the marketplace's order and poor ones sink.
- **Copyright.** As everywhere on Zaisma, a piece stays up until it's reported: Zaisma doesn't guess whether something was copied (zaisma.com/legal/copyright).
### A listing's pictures
A piece's listing can show pictures its maker made: a **cover**, which the marketplace's lists show and the listing shows first, and up to 8 **gallery pictures**: the piece itself, an art pack's own cover art, or the piece in use in a game. Keep them in the piece's folder under `listing/`, and `pieces publish` makes the listing show exactly those:
```
my-pack/
piece.json
textures/oak.png … the piece: what piece.json lists in file_paths
listing/
cover.png the cover (.png, .jpg, .jpeg or .webp)
gallery/
1-in-a-level.png gallery pictures, in name order
2-close-up.jpg
```
- **They're the listing's, never the piece's.** No statement lists them (`pieces check --fix` leaves `listing/` out of a pack's `file_paths`), nothing that adds the piece to a game gets them, and they stay as versions change.
- **What the folder doesn't say stays as it is.** No `listing/` folder changes nothing. No cover file leaves the cover; no `listing/gallery/` folder leaves the gallery. A gallery picture the folder no longer has is taken away.
- **Sizes.** A PNG, JPEG or WebP, at least 1280 by 720 px (a cover landscape, 16:9 shows best; 2560 by 1440 shows sharp on the largest screens), up to 10 MB.
- **Checked.** Each is matched against known abuse material before it's kept. A picture Zaisma doesn't take never fails the publish: the command says which and why, and `--json` answers `listing_pictures`, each `{ path, kind, picture_status, problem }` with `picture_status` `sent`, `kept`, `removed` or `refused`.
A developer's AI does the same with `add_piece_image` and `remove_piece_image`.
### Looking before getting
A listing shows what's inside a piece's newest version, so a pack is judged by its own files and not by its cover alone:
- **Pictures** (PNG, JPEG, WebP, GIF, AVIF, BMP, ICO, SVG) open whole in a viewer that steps through them.
- **3D models** (glTF as `.glb`, `.gltf` or `.vrm`; OBJ; STL) turn in a viewer: drag to turn, scroll or pinch to zoom. It draws every mesh where its scene puts it, with its base colour, its base colour picture and its vertex colours. It doesn't run animation (a rigged model stands in its bind pose), and it says so when a model's shapes are packed with Draco or Meshopt, which it can't open. A `.gltf` reads its `.bin` and its pictures from beside it in the piece.
- **Sounds** (Ogg, MP3, WAV, FLAC, M4A, AAC) play from their rows.
- Every other file is named and nothing more: text, data, code, and formats no browser shows (FBX, PSD, TIFF, MIDI).
Nothing a maker does turns this on: it's every such file of the newest version that passed its checks. The files come as they're stored from the game domain's own address for pieces, apart from zaisma.com and from every game, and that address answers only what can't run: never a script, a page or text, whatever a piece holds. A model's viewer is Zaisma's own page, framed from there, and runs nothing from the model. Anyone who can see a listing sees its previews; a private piece's open only for its maker, through an address its listing signs for an hour. Looking isn't getting: a key's say over fetching (below) holds bringing a piece's files into a project.
### What Zaisma checks
Every version passes Zaisma's fixed checks before anyone can fetch it, the same ones a game's version passes ([`docs/DEVELOPER-API.md`](DEVELOPER-API.md#the-fixed-checks-are-the-review)): no AI reads anything, and the same files always get the same answer. Then what its kind adds:
- **Packs and presets: every file is opened.** An image can only be an image, and a sound only a sound: a file whose bytes aren't what its name says refuses the version (`file_mislabeled`). The version is then marked **No code**, a guarantee that it holds no scripts or code and nothing in it can run, or **Contains code**, when a file can run (a script, a shader, a page, a program), can point at a script already in the game (an engine's own scene or resource), or is one Zaisma can't see through (an archive, a format it doesn't know). `zaisma pieces check` opens the files the same way and says which it would be.
- **Skills: text, in full.** A skill's files are all text, and its listing shows them whole, so it's read before anyone gets it. The version read is the version fetched, and a new version's listing shows what changed, line by line.
- **No programs or archives, in any kind.** A piece's files pass the same file rule as a game's: no program for Windows, macOS or Linux, no shell script (a file starting `#!`), no archive and no PDF, whatever it's called. A tool is its source, a web page or a script run with its runtime, never a built program.
- **Templates and layers** change the game they're added to, and are expected to: they run in the game's own sandbox like the rest of its code.
A finding that refuses a version comes with its fix: `file_mislabeled`, `skill_file_not_text`, or one of the fixed checks' own codes (`crypto_miner`, `disguised_code` and the rest). `needs_review` and `scan_failed` hold a version for a person at Zaisma.
### A version tells the truth
A version that keeps the first number of the one before it (the first two below `1.0.0`: `^0.2.0` takes only `0.2.x`) says nothing a game uses broke, so every game and piece built on a range like `^1.2.0` takes it. So publishing compares it with the version just below it, and refuses one that takes away or changes what games use (`piece_version_breaks`), naming each change and the version it should carry:
- **Its kind or standard** changed.
- **A setting** is gone, takes another kind of value, takes a narrower range (a higher `minimum_number`, a lower `maximum_number`, a shorter `maximum_character_count`) or loses a choice.
- **A hook** is gone or is now the other kind.
- **Its entry files** no longer export a name they did, read from the file a game imports and from a game server's, following the piece's own files they pass on whole (`export * from "./parts.js"`). Where that can't be known for sure (an entry that passes on another piece or library whole, or a file it can't read), exports are left out of the comparison.
- **A need** takes fewer versions than it did, is another kind, or is an engine it didn't need before. A new piece or library it needs is fine: adding brings it.
- **A pack's or preset's file** is gone, since a game loads them by path.
Adding a setting, a hook, an export, a choice or a wider range keeps the line, and so does a fix, a speed-up or a new default. A template is the game's own once copied, and a skill or a tool is never in a game, so they're not compared. It's a fixed check, read once when a version is published: the same two versions always get the same answer. It can't see a change in what a piece does under the same names.
### Fetching, and what an AI may fetch
A piece from another developer is a stranger's files, and a skill is a stranger's instructions to an AI. So every key and connected AI app says whether what holds it may fetch other developers' pieces, chosen when it's made (zaisma.com/dashboard/settings):
| Choice | What it does |
| --- | --- |
| Ask me first (`ask`, the default) | It fetches only the pieces you said yes to. A first try stops with `piece_approval_needed` and the piece's listing, where you read what it is and say yes or no. |
| Download freely (`free`) | It fetches any piece it can see. |
| Can't download (`none`) | It never fetches another developer's piece, or reads its files. |
Your own pieces never ask. Reading a listing and a statement is always open, and so is looking at its pictures, sounds and models there; the setting holds fetching the piece's files, code and all, into a project. It governs what comes through Zaisma: a piece that's also on npm can be had from npm.
## Errors
The command's errors, each with a `fix`:
| Code | What happened |
| --- | --- |
| `bad_piece_statement` | A piece's `piece.json` isn't one: `field` names what's wrong in it. |
| `piece_statement_newer` | A piece's `piece.json` is written for a newer command than this one: run the newest. |
| `bad_piece_source` | What was given isn't a piece's folder, its `.tgz` or a name on npm, or its archive can't be trusted. |
| `piece_not_found` | There's no such piece or version where it was looked for. |
| `piece_source_unreachable` | npm couldn't be reached, so nothing was changed. |
| `piece_not_addable` | `pieces add`: the piece is a skill or a tool, which a game never holds: `pieces get` fetches it. |
| `piece_folder_not_empty` | `pieces get`: the folder already holds files that aren't a copy of the piece. |
| `piece_not_ready` | `pieces publish`: the piece's own check found something that refuses it, so nothing was sent. |
| `piece_version_breaks` | `pieces publish`: the version keeps the first number of the one below it but takes away or changes something games use; the error names what, and the version it should carry. |
| `piece_file_changed` | A file fetched from Zaisma's marketplace isn't the one its version lists, so nothing was changed. |
| `piece_already_added` | `pieces add`: the game already has this piece at another version; a piece moves to another version only with `pieces update`. |
| `piece_not_added` | `pieces update`, `pieces remove`: the game has no such piece. |
| `piece_version_clash` | Two pieces need versions of the same thing that don't overlap, so nothing was changed; the error says both versions and the ways out. |
| `piece_need_unmet` | Something a piece needs wasn't found, so nothing was changed. |
| `piece_edited` | `pieces update`, `pieces remove`: the piece's files in the game were changed by hand; `--discard-edits` loses the edits. |
| `piece_source_needed` | `pieces update`: the piece came from a folder or a `.tgz`, so `--from` must say where the new version is, or `--from <its name>` moves it to where it's published. |
| `piece_files_differ` | `pieces update --from`: that source's copy of the same version isn't the game's files, so nothing was changed; `--discard-edits` takes that source's files. |
| `piece_not_updatable` | `pieces update`: a template is copied once and is the game's own. |
| `piece_not_removable` | `pieces remove`: a template's files are the game's own. |
| `piece_still_needed` | `pieces remove`: another of the game's pieces needs this one, so nothing was changed. |
| `template_file_exists` | `pieces add`: a template would write over a file the game already has, so nothing was changed. |
| `bad_pieces_record` | The game's `pieces/pieces.json` can't be read. |
| `pieces_record_newer` | The game's `pieces/pieces.json` was written by a newer command than this one: run the newest. |
references/saves.md
CodeCopied
# Saves
Open this when the game keeps progress.
## What Zaisma does
Cloud saves need no code. The game saves in the browser as it always would, in `localStorage` or IndexedDB; for a signed-in player, Zaisma mirrors that to their account and puts it back before the game starts on any device. Guests' progress stays in their browser. A game turns cloud saves on or off with `update_game`, `cloud_saves_enabled`.
Zaisma keeps up to 5 earlier versions of each player's save: about once an hour while they play, and whenever progress was about to be lost (another device's progress replacing it, a save that shrank to under half). The developer and their AI read, change, reset and restore any player's save with `get_save`, `change_save`, `reset_save` and `restore_save_copy`.
## When to save
- **At the moments a player would be upset to lose:** finishing a level, buying or earning something, changing settings, reaching a checkpoint.
- **When the game is hidden or closing:** on `visibilitychange` when `document.hidden`, and on `pagehide`. Phones close background tabs without warning.
- **Not every frame.** Writing storage many times a second slows the game and adds nothing.
## What goes in a save
- **Progress and settings, not the world.** Unlocked levels, inventory, currency, options, the current checkpoint. Not every enemy's position, and nothing the game can rebuild.
- **A version number in it.** Store `saveFormatVersion: 1` (or similar) beside the data, and upgrade older saves when the game loads them, so an update never breaks a player's progress.
- **Small.** A save is up to 5 MB (`save_too_big`). Keep big caches out of it: IndexedDB databases with "cache" in their name are left out of saves.
- **Plain values.** `localStorage` holds text; keep the save's shape simple enough to read back after the game changes.
## Online games
What decides a match (scores, items won, rank) belongs on the game server and in its database, not in the player's browser save, which the player controls. Purchases come from Zaisma's records (`Zaisma.items.owns()`, `Zaisma.items.owned()`), never from a save.
## In the game
A game that draws its own save screens uses `Zaisma.saves`: `listCopies()`, `getCopy(saveCopyId)` and `restoreCopy(saveCopyId)` reach the player's earlier versions, `on("conflict")` hears when two devices' progress met and which one won, and `on("developerChange")` hears when the developer changed the save. `Zaisma.player.offerAccount()` picks the moment to ask a guest to make an account and keep their progress, like after their first win.
## With the save piece
`@zaisma/save` (`npx @zaisma/cli pieces add @zaisma/save`, `pieces.md`) does all of the above for the game: a format number with `upgrades` for older saves, writes shortly after a change and at once when the game is hidden or closed, and never writes over a save from a newer version, one it can't read, or one that changed elsewhere. Name the game's pieces in its kept pieces, as below, and what they keep of their own comes back too, like the input piece's rebound controls and sensitivity. Its `index.d.ts` is the reference.
```js
const save = await openSave({ saveFormatVersionNumber: 1, defaults: { level: 1, coinCount: 0 }, keptPieces: [input] });
save.update((progress) => { progress.coinCount += 5; });
Zaisma.saves.on("developerChange", () => save.reread());
```
It keeps the save in the browser by default, so cloud saves follow it with no code. For progress kept on the game's own game server (a game also played off Zaisma, on your own server), give it a server store and answer its requests in `onRequest` with its `server.js`, the same on Zaisma's rooms and on your own server:
```js
const save = await openSave({ saveFormatVersionNumber: 1, defaults: { level: 1 }, store: serverStore({ request: (body) => Zaisma.server.request(body) }) });
// zaisma-server/index.js: import { answerSaveRequest } from "./pieces/@zaisma/save/server.js";
// onRequest: const saveAnswer = await answerSaveRequest(player, request, server); if (saveAnswer !== undefined) return saveAnswer;
```
references/sdk.md
CodeCopied
<!-- Made by scripts/build-skill.mjs: never edit it by hand. -->
# The Zaisma SDK
The game's side of Zaisma: `<script src="_zaisma/v1.js"></script>` in its index.html, and the global `Zaisma`. This is `packages/sdk/zaisma.d.ts`, served beside the SDK as `_zaisma/v1.d.ts`, with a heading per declaration.
```ts
/**
* The Zaisma SDK, typed: this file is its reference. One script tag, from the game's top folder,
* gives a browser game its players (Zaisma accounts and guests) and multiplayer rooms:
*
* <script src="_zaisma/v1.js"></script>
*
* Plain JavaScript, no dependencies, MIT licensed, and every part is optional.
*
* v1 only gains things: calls, options, fields and values are added, never renamed or removed. Page
* messages, storage keys and members whose names start with `_` are not part of v1.
*
* `Zaisma` is locked once the SDK loads: it, every namespace and every call under it can't be replaced,
* redefined, deleted or added to, so a call by Zaisma's name is always Zaisma's own. Include the SDK once,
* and never declare a `Zaisma` of your own at the top of a script (`const Zaisma = …`, `function Zaisma`):
* the browser refuses that script. Use the global `Zaisma` as it is.
*
* For editor and compiler checks, save this file beside your game's folder, not in it, since uploads
* take no .ts files. On Zaisma it's served beside the SDK as _zaisma/v1.d.ts; in Zaisma's repository
* it's packages/sdk/zaisma.d.ts. Then put `/// <reference path="../zaisma.d.ts" />` (and in JavaScript,
* `// @ts-check`) at the top of your script, or list it in jsconfig.json or tsconfig.json. The
* global `Zaisma` is then typed, and its types are `Zaisma.Room`, `Zaisma.JoinOptions` and so on (in
* JavaScript, give `let room = null` a JSDoc `@type {Zaisma.Room | null}`, as the example games do).
*
* Names follow Zaisma's naming guide: whole words, the unit in the name (`idleTimeoutSec`), and is, has
* or can for yes or no. An option or event the SDK doesn't take is refused with the list of the ones it
* does (`error.code` "unknown_option" or "unknown_event"), so a misspelled or old one never goes
* quietly unused. Errors carry `error.code` ({@link Zaisma.ErrorCode}).
*
* Within v1, codes and events only grow: handle unknown ones (a `default` branch), and a new code or event
* never breaks your game.
*
* The Zaisma button shares your game's screen: while it plays on Zaisma, the button sits in the top right
* corner of the game's frame, over the game, about 64 by 60 CSS px past the phone's safe area. On phones and
* touch screens it's always there; with a mouse it slides in when the pointer reaches that corner. Keep your
* own buttons, score and words out of that corner. The developer API's preview_game_page pictures the game
* playing with the button in place, on a laptop and a phone.
*
* Player passes, for rooms and your own servers, need the game played on its zaisma.com page, which
* checks the browser on Play: joining fails with `error.code` "unchecked" when it couldn't, or when the
* game was opened anywhere else. A game played off Zaisma (exported, on another site, wrapped for a store)
* plays online against your own game server only: call {@link Zaisma.setUpOffZaisma} first, and give
* joinRoom and server.request a serverUrl; without them they fail with "not_on_zaisma".
*
* @example
* const room = await Zaisma.joinRoom(); // joins ?room=CODE if the link has one, else makes a room
* room.me; room.players; room.roomCode; room.inviteUrl;
* room.on("message", (message) => {}); // from the game server
* room.on("players", (players) => {});
* room.on("connectionStatus", (connectionStatus) => {});
* room.on("ended", ({ message, endReason }) => {});
* room.send({ move: "left" });
* room.leave();
* await Zaisma.invite(room); // share sheet on phones, copies the link elsewhere
*/
```
## Calls
### Zaisma.sdkVersionNumber
```ts
/** The SDK's version: 1 for _zaisma/v1.js. */
const sdkVersionNumber: 1;
```
### Zaisma.gameSlug
```ts
/** The game's slug, as in zaisma.com/g/<slug>, or null outside Zaisma. */
const gameSlug: string | null;
```
### Zaisma.player
```ts
/** This tab's player: their pass, profiles, and asking a guest to sign in. */
const player: {
/**
* This tab's player, with their player pass: the signed-in Zaisma account, with the same player ID in
* every game, or a guest. joinRoom gets one by itself; call this to let the player into a server of
* your own. A guest's is kept for the tab, so a guest who reloads stays the same guest, and renewed when
* it has under 10 minutes left or the player signs in; an account gets a new one each time the game
* loads, for whoever is signed in then. Fails with error.code "unchecked" when the
* game isn't played on its zaisma.com page, "not_on_zaisma" when it isn't hosted on Zaisma, and
* "account_needed" for a guest when the game needs an account for multiplayer or the whole game
* (its account_requirement setting): ask them to sign in with Zaisma.player.signIn().
*
* @example
* const mine = await Zaisma.player.getPass(); // { id, name, kind, pass, expiresAt }
* socket.send(JSON.stringify({ pass: mine.pass }));
*/
getPass(): Promise<PlayerWithPass>;
/**
* An account's public profile by player ID, what anyone sees of it, like a name for a leaderboard
* row. Fails with error.code "no_player" for a guest's ID or a deleted account's, and
* "bad_player_id" for anything that isn't a player ID.
*
* @example
* const profile = await Zaisma.player.getProfile("player_8f3k2m");
* scoreRow.textContent = profile.name; // the username: nobody can pass as someone else
*/
getProfile(playerId: string): Promise<PlayerProfile>;
/**
* Ask a guest to sign in with their Zaisma account, without leaving the game. Zaisma's page shows a
* small card beside the game ("Sign in" or make a free account, and "Not now"); signing in opens a
* new tab, so the game keeps running. Resolves with the account once the player has signed in, and
* at once when they already are. From then on Zaisma.player.getPass() and joinRoom give the account's pass;
* rooms the player is already in keep them as the guest they joined as, so join again to play as
* the account. Call it when the player presses something that needs an account, like Play online
* in a game whose multiplayer needs one (joinRoom failed with "account_needed"), or Save to
* leaderboard. A second call while the card is up waits for the same answer. Fails with error.code
* "sign_in_declined" when the player chose Not now, and "not_on_zaisma" when the game isn't played
* on its zaisma.com page. There's no time limit: the player may take a few minutes.
*
* @example
* try {
* room = await Zaisma.joinRoom();
* } catch (error) {
* if (error.code !== "account_needed") throw error;
* await Zaisma.player.signIn(); // { id, name, kind: "account" }
* room = await Zaisma.joinRoom();
* }
*/
signIn(): Promise<Player>;
/**
* Show Zaisma's "Keep your progress" card at the moment the game picks, like right after the player
* beat a level or found something rare. It's the same card a guest gets by itself after 5 minutes of
* play (account_offer_enabled; turn that off to pick every moment yourself): it offers a free account
* so their progress is kept, beside the game, and making one opens a new tab, so the game keeps
* running. Because it's Zaisma's card, Zaisma's rule on how often holds, however the game asks: at
* most once a visit, and not for 3 days after the player chose Not now. Resolves with the account
* once the player has one, and at once when they're signed in already. A second call while the card
* is up waits for the same answer. There's no time limit: the player may take a few minutes.
*
* Fails with error.code "account_offer_too_soon" when the card already showed this visit or the
* player chose Not now in the last 3 days (the game can't see the card, so it hears it here; show your
* own message if you like), "sign_in_declined" when the player chose Not now, "cloud_saves_off" when
* the game has cloud saves off (no progress for the card to keep: ask with Zaisma.player.signIn()
* instead), "cloud_saves_not_here" when cloud saves don't work where it's played (a tester link, or a
* Zaisma without accounts), and "not_on_zaisma" when the game isn't played on its zaisma.com page.
*
* @example
* async function levelBeaten() {
* try {
* const account = await Zaisma.player.offerAccount(); // { id, name, kind: "account" }
* showNote("Your progress follows you now, " + account.name + ".");
* } catch (error) {
* if (error.code !== "account_offer_too_soon" && error.code !== "sign_in_declined") throw error;
* }
* }
*/
offerAccount(): Promise<Player>;
};
```
### Zaisma.joinRoom()
```ts
/**
* Join a room: the one joinOptions.roomCode names, else the one the page's link points to
* (?room=CODE, on the same server: {@link Rooms.linkedServerUrl}), else a new room. Resolves once the
* room has let the player in, so room.me and room.players are set. On your own servers (serverUrl),
* it also tells Zaisma which room a signed-in player is in, and that they left it, so their friends'
* Join works there too ({@link Friends.setRoom}).
*
* Fails with an error whose code says why and whose message says it in words. The room won't take
* the player: full, closed (to new players), ended, kept_out (removed for the rest of the match),
* refused (the game server's canJoin said no; the message is its refusalMessage), hosting_paused (the
* game's hosting is paused this month: its free allowance or its developer's budget or credit is used). No player pass: unchecked, or account_needed for a
* guest when the game needs accounts (see Zaisma.player.getPass()). The
* call is set up wrong: unknown_option, bad_room_code, bad_server_url, bad_transport, not_on_zaisma (the game is played
* off Zaisma without a serverUrl, or before {@link setUpOffZaisma}). Off Zaisma, bad_player_token: your server
* didn't take the playerToken (get the player a new one and call setUpOffZaisma again). Or connection_closed (the connection closed first, say the game left or the player
* joined from another tab) and request_failed (Zaisma didn't answer). {@link ErrorCode} has them all.
*
* @example
* const room = await Zaisma.joinRoom();
* Zaisma.joinRoom({ joinData: { character: "knight" } }); // for the game server's canJoin and onJoin
* Zaisma.joinRoom({ isListed: true }); // others find it in room lists
* Zaisma.joinRoom({ name: "Ana's castle", labels: { Mode: "Classic", Map: "Docks" } });
* Zaisma.joinRoom({ idleTimeoutSec: 300 }); // ask "Still there?" after 5 minutes without input
* Zaisma.joinRoom({ serverUrl: "wss://play.example.com" }); // your own game server
*/
function joinRoom(joinOptions?: JoinOptions): Promise<Room>;
```
### Zaisma.setUpOffZaisma()
```ts
/**
* Set up a game played off Zaisma (exported, on another site, wrapped for a store) to play online against
* your own game server. Off Zaisma there's no Zaisma pass, so joinRoom and server.request with a serverUrl
* send the playerToken in its place, and your server says who the player is (startServer's identifyPlayer):
* a Sign in with Zaisma ID token (same player ID and name as on Zaisma), your game's own token, or null for
* a guest when your server lets guests in (outsideGuestsEnabled). They join with kind "outside_zaisma",
* in the same rooms as players from your Zaisma page.
*
* On a Zaisma page it changes nothing and resolves { isOffZaisma: false }, so the same code runs in both
* places. Call it again to replace the token (a new sign-in, or signing out); rooms use the newest one when
* they reconnect. Off Zaisma there's no Zaisma bar, saves, buy sheet, friends or room lists.
*
* Fails with error.code unknown_option, bad_game_slug (not a game slug) and bad_player_token (not text up to 8 KB, or null).
*
* @example
* await Zaisma.setUpOffZaisma({ gameSlug: "star-raiders", playerToken: idToken });
* const room = await Zaisma.joinRoom({ serverUrl: "wss://play.example.com" });
*/
function setUpOffZaisma(setUpOptions: SetUpOffZaismaOptions): Promise<OffZaismaSetup>;
```
### Zaisma.rooms
```ts
/** Room browsing: the game's listed rooms, which show on its Zaisma page and to the game itself. */
const rooms: Rooms;
```
### Zaisma.server
```ts
/** The game's own game server outside any room: requests to its onRequest. */
const server: Server;
```
### Zaisma.invite()
```ts
/**
* Invite friends. On Zaisma it opens Zaisma's invite sheet, the same as the guide's Share: the
* room's QR code, link and code, Copy and the share sheet ("opened", or "failed" when the page couldn't
* open it). On your own site it opens the share sheet on phones, otherwise copies the room's invite link
* (the game's page without a room). Call it from a button in your game, like on a "waiting for players"
* screen: it opens only right after the player taps or presses a key in the game, so call it from that
* tap's handler, and it fails with error.code "needs_player_tap" otherwise. On a page that isn't
* Zaisma's, around a game hosted on Zaisma, it fails with "not_on_zaisma".
*
* @example
* if ((await Zaisma.invite(room)) === "copied") inviteButton.textContent = "Link copied";
*/
function invite(room?: Room | null): Promise<InviteStatus>;
```
### Zaisma.checkChat()
```ts
/**
* Zaisma's chat check: the same check Zaisma runs on its side on every chat message to or from an
* under-18 account. It stops contact details in any disguise, moving to another app or meeting up,
* personal details and sexual content, and answers with the words to show the sender. Swearing and
* slurs are flagged (hasSwearing, hasSlur) but allowed: blocking them is your game's call. For chat
* between players use {@link Room.chat}, which runs this check on its way; this one is for other text
* players type. Checks the whole text, up to 2000 characters; a longer one is refused (too_long), never cut.
*
* @example
* const check = await Zaisma.checkChat(typedMessage);
* if (!check.isAllowed) showError(check.message);
* else if (check.hasSwearing) showError("No swearing in this game."); // your call
* else send(check.text);
*/
function checkChat(text: string): Promise<ChatCheck>;
```
### Zaisma.friends
```ts
/**
* The signed-in player's Zaisma friends who are playing this game right now, for your own list of
* them: to join a friend's match, watch it or invite them ({@link Friends.list}). A game never sees
* friends who aren't playing it, or who's online.
*/
const friends: Friends;
```
### Zaisma.links
```ts
/**
* The game's registered links: the sites on its details that it opens, like its store, Patreon,
* Steam page or Discord ({@link Links.open}). The game can open no other sites.
*/
const links: Links;
```
### Zaisma.items
```ts
/**
* The game's items: what the player owns (from their player pass, so it matches what the game's server
* sees) and what the game sells, priced in the player's currency. Developers set items with set_item;
* buying comes with Zaisma's buy sheet.
*/
const items: Items;
```
### Zaisma.saves
```ts
/**
* The player's cloud saves, for games that draw their own save screens. With cloud saves on, Zaisma
* copies the game's own browser saves (localStorage and IndexedDB) to a signed-in player's account
* with no code, and keeps 5 earlier versions. When two devices played on, the progress played most
* recently wins and the other is kept as an earlier version: listen for "conflict" to offer the
* player the other one. When you change a player's save through the API or MCP, the game reloads with
* it, unless it listens for "developerChange" and rereads its storage instead. Guests' progress stays
* in their browser, so the calls fail with "account_needed" for them.
*
* Every call fails with error.code "account_needed" for a guest, "cloud_saves_off" when the game has
* cloud saves off, "cloud_saves_not_here" when they don't work where it's played (a tester link, or a
* Zaisma without accounts), "not_on_zaisma" when the game isn't played on its zaisma.com page,
* "slow_down" and "request_failed".
*/
const saves: Saves;
```
### Zaisma.versions
```ts
/**
* A version the developer published with match_update_mode "now", for a game that isn't in a match
* (single-player, or in a menu): it's never forced on the player. Listen for "update" and call
* update.apply() when it suits the game, like at a checkpoint or back at the main menu: the page
* reloads the game at the new version, with its save. Without a listener, Zaisma offers Update beside
* the game, and the player gets it then, or the next time they open the game. Matches hear theirs from
* the room instead (the room's "versionUpdate" event).
* @example
* Zaisma.versions.on("update", (update) => {
* if (isAtMainMenu()) update.apply();
* else pendingUpdate = update; // apply it when the player is back at the menu
* });
*/
const versions: Versions;
```
### Zaisma.page
```ts
/**
* Whether Zaisma's page covers the game right now, so a game can pause or hold the player's input while it does.
* coveredBy is "sheet" while one of Zaisma's sheets is open over the game (buying, the guide, Report: the player is
* busy with it), "card" while one of its cards is over the game's corner (Still there?, Keep your progress; the
* game stays in view and playable), and null otherwise. Always null outside Zaisma's page (your own site, a
* local test). Listen for "coveredBy" to hear each change.
* @example
* Zaisma.page.on("coveredBy", (coveredBy) => {
* if (coveredBy === "sheet") pauseGame();
* else resumeGame();
* });
*/
const page: Page;
```
## Types
### SetUpOffZaismaOptions
```ts
/** Options for {@link setUpOffZaisma}. */
interface SetUpOffZaismaOptions {
/** Your game's slug, as its Zaisma link names it, like "star-raiders": the address your server's rooms and requests take. */
gameSlug: string;
/** The player's token for your own server, text up to 8 KB: a Sign in with Zaisma ID token or your game's own. Null or left out for a guest. */
playerToken?: string | null;
}
```
### OffZaismaSetup
```ts
/** What {@link setUpOffZaisma} answers. */
interface OffZaismaSetup {
/** False on a Zaisma page (nothing changed); true elsewhere, where joins and requests now carry the playerToken. */
isOffZaisma: boolean;
}
```
### Friends
```ts
/** The player's friends playing this game ({@link friends}). */
interface Friends {
/**
* The player's friends playing this game right now, in any of its rooms or none, as each friend's
* settings let the player see them: someone who hides what they're playing or appears offline isn't
* listed. Each comes with the room to join them in when the player could join it, and otherwise why
* not, the same reasons Join gives on zaisma.com/friends. Kept for 10 seconds, so call it whenever
* your list opens. Fails with error.code "account_needed" for a guest (ask them to sign in with
* {@link player.signIn}), and "not_on_zaisma" when the game isn't hosted on Zaisma.
*
* @example
* const { friends } = await Zaisma.friends.list();
* for (const friend of friends) {
* if (friend.roomCode) addRow(friend.name, () => Zaisma.joinRoom({ roomCode: friend.roomCode, serverUrl: friend.serverUrl ?? undefined }));
* else addRow(friend.name, null, friend.joinRefusal); // like "room_full" or "friend_not_in_room": see FriendJoinRefusal
* }
*/
list(): Promise<FriendList>;
/**
* Say which room on your own servers the player is in, or null when they left it, so their friends'
* Join on Zaisma takes them there: a link to your game's page with ?room=CODE&server=… that
* joinRoom({ serverUrl }) follows (see {@link Rooms.linkedServerUrl}). joinRoom({ serverUrl }) does this by
* itself, so call it only when your game has its own netcode. The server must be one of the game's
* own servers, own_server_urls (error.code "unlisted_server" otherwise), and Zaisma rooms need
* none of this. The SDK says it again every 2 minutes while the page is open, and a room it stops
* saying drops off after 5. For a guest it does nothing: guests have no friends. Your server keeps
* its own door: a friend's Join is only a room link.
*
* @example
* await Zaisma.friends.setRoom({ serverUrl: "wss://play.example.com", roomCode: "K7Q2MX" });
* await Zaisma.friends.setRoom(null); // left the match
*/
setRoom(room: OwnServerRoom | null): Promise<void>;
/**
* Offer the player to send another player a friend request, from your own scoreboard, lobby or menu.
* Zaisma asks the player first on its page ("Send Mia a friend request?", with the name Zaisma knows
* them by), so nothing is sent without them, and the other player gets it over their game's corner and
* on zaisma.com/friends. Players can also send one from Players in Zaisma's bar, so a button of your
* own is optional. Resolves with what happened: "sent"; "cancelled" when the player said no or another
* question was up; "already_friends"; or "not_taking_requests" when the other player doesn't take them
* from this one (their settings, their age group, a block, or a guest), which never says which. Your game
* never hears of requests themselves, only that two players are friends (room.areFriends on your game server, and the
* passes' tags, from their next join). Fails with error.code "account_needed" for a guest (ask them to
* sign in with {@link player.signIn}), "bad_player_id" for something that isn't a player's id, and
* "not_on_zaisma" when the game isn't played on Zaisma.
*
* @example
* // A button beside each player on your end-of-match screen.
* const { status } = await Zaisma.friends.sendRequest(player.id);
* if (status === "sent") button.textContent = "Request sent";
*/
sendRequest(playerId: string): Promise<FriendRequestAnswer>;
}
```
### FriendRequestAnswer
```ts
/** What became of a friend request the game offered ({@link Friends.sendRequest}). */
interface FriendRequestAnswer {
status: FriendRequestStatus;
}
```
### FriendRequestStatus
```ts
/** "sent", "cancelled" (the player said no), "already_friends", or "not_taking_requests" (never why). */
type FriendRequestStatus = "sent" | "cancelled" | "already_friends" | "not_taking_requests";
```
### FriendList
```ts
/** The player's friends playing this game ({@link Friends.list}). */
interface FriendList {
/** By name. Empty when none of them are playing it. */
friends: FriendInGame[];
}
```
### FriendInGame
```ts
/** A friend playing this game. */
interface FriendInGame {
/** Their player ID, the same in every game, as in room.players. */
id: string;
/** The name to show for them: their username. */
name: string;
username: string;
/** The room to join them in, when the player could join it; null otherwise, with joinRefusal. */
roomCode: string | null;
/** Your own server that room is on, for joinRoom's serverUrl; null for a Zaisma room, or with no room. */
serverUrl: string | null;
/** Why the player can't join them, or null when they can. */
joinRefusal: FriendJoinRefusal | null;
}
```
### FriendJoinRefusal
```ts
/**
* Why the player can't join a friend, the same reasons Join gives on zaisma.com/friends, in this order:
* - game_not_taking_joins: your game turned Join off (friend_joins_enabled false in its settings).
* - friend_not_taking_joins: the friend's own setting doesn't let this player join them.
* - private_room: your game turned Join off for their room ({@link Room.setFriendJoinsEnabled}).
* - room_closed: their room is closed to new players.
* - room_full: their room has no space (players and held seats).
* - spectators_full: their room takes no more spectators, for Watch.
* - friend_not_in_room: they're playing, but not in a room your game told Zaisma of (a Zaisma room, or one on your own servers through {@link Friends.setRoom}).
*
* More reasons may come within v1: show a plain "can't join" for one you don't know.
*/
type FriendJoinRefusal = "game_not_taking_joins" | "friend_not_taking_joins" | "private_room" | "room_closed" | "room_full" | "spectators_full" | "friend_not_in_room";
```
### OwnServerRoom
```ts
/** A room on the game's own servers ({@link Friends.setRoom}). */
interface OwnServerRoom {
/** The server, starting with wss:// or https://, like "wss://play.example.com": one of the game's own servers (own_server_urls). */
serverUrl: string;
/** Its room code: six characters like "K7Q2MX", from 2 to 9 and A to Z without I or O. */
roomCode: string;
/** false: friends' Join shows grayed as "Private room" instead of taking them there. Default true. */
friendJoinsEnabled?: boolean;
}
```
### Links
```ts
/** The game's registered links ({@link links}). */
interface Links {
/**
* Open one of the links registered on the game's details, by its link_name, in a new tab. Call it
* from the player's tap or key press, like a Support us button: links open only right after one, so
* nothing ever opens by itself (error.code "needs_player_tap" otherwise). On Zaisma, the page shows a
* card over the game's top corner: "You're leaving Zaisma", your game's name, the full address, Open
* and Stay. The game keeps running behind it. Resolves with "opened" when a new tab opened, and
* "stayed" when the player chose Stay or the link can't open for them: guests and under-18 accounts
* open only links on trusted store, payment and video sites, never chat apps like Discord, and see
* "This link can't be opened here." instead. The game hears the same "stayed" either way, so it never
* learns why. Your dashboard and get_game say who each link opens for (who_can_open).
*
* Add a path and query under the link's address, so a store can tell what was bought and by whom:
* the link https://kit.itch.io/sky-hopper with path "/buy" opens https://kit.itch.io/sky-hopper/buy.
* Another site, or a path outside the link's, never opens.
*
* On your own site there's no Zaisma page to look the link up, so give its address there as
* ownSiteUrl, and it opens straight away. On Zaisma, the registered address opens, whatever
* ownSiteUrl says.
*
* Fails with error.code: unknown_link (no link by that name on the game), bad_link_path,
* bad_link_query (also when the link's own address already sets that name), bad_own_site_url,
* needs_player_tap, not_on_zaisma (outside Zaisma without ownSiteUrl), unknown_option, slow_down and
* request_failed.
*
* @example
* supportButton.onclick = () => Zaisma.links.open("patreon");
* buyButton.onclick = async () => {
* const linkStatus = await Zaisma.links.open("store", { path: "/buy", queryParameters: { item: "sword", player: playerId } });
* if (linkStatus === "opened") showNote("Finish buying in the new tab.");
* };
* Zaisma.links.open("store", { ownSiteUrl: "https://kit.itch.io/sky-hopper" }); // also works on your own site
*/
open(linkName: string, linkOptions?: LinkOptions): Promise<LinkStatus>;
}
```
### Items
```ts
/** The game's items ({@link items}). */
interface Items {
/**
* Whether the player owns a permanent item (bought or granted, not refunded), by its item_name, as their
* player pass says: a new pass (at most a day old) brings new items. false for guests, who own nothing.
* Fails with error.code bad_item_name, not_on_zaisma, unchecked, account_needed and request_failed, as
* Zaisma.player.getPass() does.
*
* @example
* if (await Zaisma.items.owns("skin_red-dragon")) unlockSkin("red-dragon");
*/
owns(itemName: string): Promise<boolean>;
/** Every permanent item the player owns, by item_name; [] for guests. Fails as {@link Items.owns} does. */
owned(): Promise<string[]>;
/**
* The items the game sells, at the price this player pays: in their currency when the game set a price
* for it (picked by the player's country), else the main price. Show priceText beside anything sold for
* coins or gems too: real prices are always shown. Fails with error.code not_on_zaisma, bad_origin,
* game_unavailable and request_failed.
*
* @example
* for (const item of await Zaisma.items.list()) addShopRow(item.title, item.priceText, item.isOwned);
*/
list(): Promise<ItemForSale[]>;
/**
* Buy an item through Zaisma's buy sheet: on the game's zaisma.com page it slides up over the game, which
* keeps running; on your own site a zaisma.com window opens. The player pays you through your own Stripe
* account (get_stripe_account), with no cut. Call it from a tap or key press handler. Every player outcome
* resolves: "bought" (the player's pass owns it at once; pass purchase.receipt to your server to check),
* "cancelled" (nothing was charged: the player closed the sheet, or already owned the item) or "failed"
* (declined, or still settling when the sheet closed: a "purchase" event follows if it completes later).
* Fails with error.code needs_player_tap, bad_item_name, no_item, no_game, not_for_sale,
* stripe_not_connected, stripe_cannot_take_payments, bad_item_count, bad_game_account_id, unknown_option,
* not_on_zaisma and request_failed: your mistakes, never the player's; for the ones Zaisma finds,
* error.message ends with the fix (finish setting up Stripe, connect_stripe_account, set_item).
*
* @example
* buyButton.onclick = async () => {
* const bought = await Zaisma.items.buy("revive");
* if (bought.status === "bought") revivePlayer();
* };
*/
buy(itemName: string, buyOptions?: BuyOptions): Promise<BuyResult>;
/**
* Listen for the buy sheet opening and closing, and for a purchase on its way to the game (the
* {@link ItemsEvents}). Purchases come when the game's purchase
* settings say purchase_delivery "game": the game calls {@link Items.markHandled} first, then hands it
* over, so a second tab, which gets "already_handled", skips it and it comes once. Each one waiting comes once the game listens, and each new one after the
* buy sheet completes it. A wrong name fails with error.code "unknown_event". With "game_server",
* the game server's onPurchase takes purchases instead, and "purchase" and "refund" never fire.
*
* @example
* Zaisma.items.on("purchase", async (purchase) => {
* await Zaisma.items.markHandled(purchase.id); // already_handled: another tab took it
* if (purchase.itemName === "revive") addRevives(purchase.itemCount);
* });
*/
on<EventName extends keyof ItemsEvents>(event: EventName, listener: ItemsEvents[EventName]): this;
/** Stop listening. */
off<EventName extends keyof ItemsEvents>(event: EventName, listener: ItemsEvents[EventName]): this;
/**
* The player's purchases the game hasn't marked handled, oldest first: each
* completed one, and each taken back (purchaseStatus "refunded" or "charged_back") after it was
* handled; at most 50 purchases and 50 refunds at a time. [] for guests, who buy nothing. Fails as {@link Items.owns} does, and with "slow_down".
*/
unhandled(): Promise<Purchase[]>;
/**
* Mark a purchase handed over, so it doesn't come again (or, for one taken back, its refund). Fails
* with error.code "bad_purchase_id", "no_purchase" (not this player's, or not paid), "already_handled"
* (another tab or device took it first: don't hand it over twice), "handled_by_server" (purchase_delivery
* isn't "game": the game server or the developer's own server marks it), "slow_down", and as
* {@link Items.owns} does.
*
* @example
* await Zaisma.items.markHandled(purchase.id);
*/
markHandled(purchaseId: string): Promise<void>;
}
```
### ItemsEvents
```ts
/** The events of {@link items}, each with what its listener gets. */
interface ItemsEvents {
/** A completed purchase the game hasn't handled yet: mark it handled, then add what it bought. */
purchase: (purchase: Purchase) => void;
/**
* A purchase taken back (refunded or charged back) after the game handled it: the game decides what to
* take back, after marking it handled. A permanent item leaves {@link Items.owned} by itself.
*/
refund: (purchase: Purchase) => void;
/** The buy sheet opened over the game, which keeps running: pause it here if it shouldn't. */
sheetOpen: (sheet: SheetEvent) => void;
/** The buy sheet closed, bought or not; {@link Items.buy} says how it ended. */
sheetClose: (sheet: SheetEvent) => void;
}
```
### SheetEvent
```ts
/** Which item the buy sheet is for ({@link ItemsEvents}). */
interface SheetEvent {
itemName: string;
}
```
### BuyOptions
```ts
/** How {@link Items.buy} buys. */
interface BuyOptions {
/** How many of a consumable item, from 1 (1 unless you say). A permanent item is always 1. */
itemCount?: number;
/** Your game's own account ID for the player, kept on the purchase and its receipt; null unless you say. */
gameAccountId?: string | null;
}
```
### BuyResult
```ts
/** How a buy ended ({@link Items.buy}). */
interface BuyResult {
/**
* bought: the player paid. cancelled: nothing was charged (the player closed the sheet before paying, or
* already owned the item). failed: the payment was declined, or was still settling when the sheet closed;
* if it completes later, the "purchase" event fires for it.
*/
status: "bought" | "cancelled" | "failed";
/**
* The same {@link Purchase} the "purchase" event hands over, with its receipt when bought. On failed it's
* the purchase when there is one (purchaseStatus "pending" or "failed", receipt ""); null on cancelled.
*/
purchase: Purchase | null;
}
```
### Purchase
```ts
/** A purchase on its way to the game ({@link ItemsEvents}), and the one a {@link BuyResult} carries, as the API's purchase in camelCase. */
interface Purchase {
/** Like "purchase_8f2k1x". */
id: string;
itemName: string;
itemKind: "permanent" | "consumable";
/** How many of the item: 1 for permanent items. */
itemCount: number;
/** sale: bought on the buy sheet. grant: given by the developer (grant_item). */
purchaseSource: "sale" | "grant";
/** "pending" and "failed" appear only on a failed {@link BuyResult}'s purchase; the events carry the rest. */
purchaseStatus: "completed" | "refunded" | "charged_back" | "pending" | "failed";
/** The game's own account ID for the player, when the game gave one to buy or grant_item; else null. */
gameAccountId: string | null;
/** What it paid, in the currency's minor units (cents); null for a grant. */
paidMinorUnits: number | null;
/** Like "EUR"; null for a grant. */
currencyCode: string | null;
/** When it was bought or granted, an ISO time. */
purchasedAt: string | null;
/**
* When the item was taken back, an ISO time: a full refund or a chargeback (purchaseStatus "refunded" or
* "charged_back"); null otherwise. A partial refund leaves the player owning the item and shows only in
* the API's refunded_minor_units, so test purchaseStatus, not just refundedAt, for what the player owns.
*/
refundedAt: string | null;
/** The signed receipt, for a server of the game's own to check (verifyReceipt in @zaisma/game-server). "" on a failed {@link BuyResult}'s purchase, which never completed. */
receipt: string;
}
```
### ItemForSale
```ts
/** One item the game sells, for this player ({@link Items.list}). */
interface ItemForSale {
itemName: string;
title: string;
/** "" for none. */
description: string;
/** permanent: owned for good, on every device. consumable: delivered once, then the game keeps count. */
itemKind: "permanent" | "consumable";
itemCategory: "cosmetic" | "gameplay" | "content" | "currency";
/** The price this player pays, in the currency's smallest unit (cents; yen are whole), tax included. */
priceMinorUnits: number;
/** Lowercase ISO 4217, like "usd" or "brl". */
currencyCode: string;
/** The price as the player reads it, like "$1.99" or "R$ 59,90". */
priceText: string;
/** The player owns it (a permanent item), by their pass. */
isOwned: boolean;
}
```
### Page
```ts
/** Whether Zaisma's page covers the game ({@link page}), the game's two calls on it, and its game view. */
interface Page {
/** "sheet", "card" or null: what of Zaisma's is over the game now. Read-only. */
readonly coveredBy: CoveredBy;
/**
* Why this page loaded: "version_update" when Zaisma reloaded it to move to the version that went live (a match
* update "now"), "player" when the player reloaded it, null on a first load. Set once, as the page loads.
* @example
* if (Zaisma.page.reloadReason === "version_update") showToast("Updated: you're back in your room");
*/
readonly reloadReason: "version_update" | "player" | null;
/**
* The codes of the rooms this tab was in before it reloaded, as a player (not watching): rejoin them with
* Zaisma.rooms.join(code). Empty on a first load.
*/
readonly previousRoomCodes: string[];
/**
* Opens Zaisma's player card for a player in the game's room, on that player's press in your game (a Card button on a scoreboard): who they are, how
* the player knows them, Add friend, Mute, Block and Report. Only a player in the room the game is in; the guide beside the game shows it. It opens
* only right after the player's own press, as Zaisma.invite does: called at any other time, nothing opens.
* Fails with error.code "bad_player_id" for something that isn't a player's id, and "not_on_zaisma" off Zaisma's page.
* @example
* cardButton.onclick = () => Zaisma.page.openPlayerCard(player.id);
*/
openPlayerCard(playerId: string): Promise<void>;
/**
* Ends play from the game's own menu, after its own confirm: the player lands on the game's page, where the guide's Leave lands. Fails with
* error.code "not_on_zaisma" off Zaisma's page, where the game ends play its own way.
* @example
* quitConfirm.onclick = () => Zaisma.page.leave();
*/
leave(): Promise<void>;
/**
* Turns off what Zaisma does so play feels like an app, for a game that needs the browser's own way back. Zaisma's own (full screen, the screen
* awake, the leave check) are true until the game says false; the browser's habits (zoom, text selection, its menu, page scrolling, its shortcuts,
* dragging, keyboard focus) are false until the game says true ({@link GameView}). Only the names given change; call it as often as you need,
* for one screen of the game or for all of it. Off Zaisma's page there's nothing to turn off: it resolves and does nothing.
* Fails with error.code "unknown_option" for a name it doesn't take, and "bad_game_view" for a value that isn't true or false.
* @example
* // A game with a code the player copies out of it.
* await Zaisma.page.setGameView({ textSelectionEnabled: true });
*/
setGameView(changes: Partial<GameView>): Promise<void>;
/**
* Opens Zaisma's feedback sheet beside the game from the game's own menu, on the player's own press (a Send feedback button): the player picks
* what it is, writes a line if they want and sends it, with a picture of the game as it was and the moments they marked, straight to you
* (get_feedback, the feedback_sent webhook event). gameContext says where the player is, as {@link setFeedbackContext} does, for this one.
* It opens only right after the player's own press: called at any other time it fails with error.code "feedback_not_opened". Resolves once they
* send it; fails with "feedback_not_sent" when they close it without sending, "bad_game_context" for a gameContext it can't take, and
* "not_on_zaisma" off Zaisma's page. The game never learns what they wrote or who they are.
* @example
* feedbackButton.onclick = () => Zaisma.page.openFeedback({ gameContext: { level: currentLevel, area: currentArea } }).catch(() => {});
*/
openFeedback(options?: { gameContext?: FeedbackContext }): Promise<void>;
/**
* Says where the player is, so it goes with any feedback they send from the guide or the leave step too: up to 8 short facts, each name up to
* 40 characters and each value up to 100 (a string, number or true or false). Kept until you call it again; {} clears it. Off Zaisma's page it
* resolves and does nothing. Fails with error.code "bad_game_context" for an object it can't take.
* @example
* Zaisma.page.setFeedbackContext({ map: "Docks", round: 4, isRanked: true });
*/
setFeedbackContext(gameContext: FeedbackContext): Promise<void>;
/** Listen for "coveredBy": called with the new value each time it changes. A wrong name fails with error.code "unknown_event". */
on(event: "coveredBy", listener: (coveredBy: CoveredBy) => void): Page;
off(event: "coveredBy", listener: (coveredBy: CoveredBy) => void): Page;
}
```
### GameView
```ts
/**
* The game view ({@link Page.setGameView}): while a game plays it gets every input, as an app or a console game would. The browser keeps only the
* player's ways out (Shift Tab to Zaisma, holding Esc, closing the tab, the phone's own home gesture). The game's screen_orientation holds a phone
* to it where the phone allows, and turns off with "either".
*/
interface GameView {
/**
* Play takes the whole screen on phones, tablets and Xbox, and on computers in Chrome and Edge, where the keyboard is held for the game too (Esc and
* the browser's shortcuts reach it; holding Esc leaves full screen). Safari and Firefox on computers fill the window; an iPhone has no full screen.
* false leaves it, now and on Play. Default true.
*/
fullScreenEnabled: boolean;
/** The screen stays awake while the game plays. Default true. */
screenAwakeEnabled: boolean;
/** Back (a swipe, a phone's Back, a mouse's or a controller's) and closing the tab ask "Leave the game?" first. Default true. */
leaveCheckEnabled: boolean;
/** A pinch or a double tap zooms, as on a web page. Default false. */
zoomEnabled: boolean;
/** A press or a drag highlights text, and iOS's editing gestures work, as on a web page. Text fields always can. Default false. */
textSelectionEnabled: boolean;
/** A right click or a long press opens the browser's own menu. Text fields always do. Default false. */
browserMenuEnabled: boolean;
/** The wheel, a trackpad, the arrows, Space and Page Up and Down scroll the game's page, and the middle button autoscrolls. What the game scrolls itself always does. Default false. */
pageScrollEnabled: boolean;
/** The browser's shortcuts (find, save, print, bookmark, zoom, help, Firefox's quick find) and a mouse's side buttons going Back and Forward, and in full screen the keyboard isn't held. Default false. */
browserShortcutsEnabled: boolean;
/** Pictures and links drag out of the game, and a file dropped on it opens in its place. A game's own draggable elements and drops always work. Default false. */
dragEnabled: boolean;
/** Tab moves between the game's buttons and fields (and out of the game at the end), with focus rings, as on a web page. Shift Tab always reaches Zaisma. Default false. */
keyboardFocusEnabled: boolean;
/** F8 marks a moment for the player's feedback: its picture and time, with Marked from Zaisma's corner, and nothing opens. false gives F8 to the game; holding the Z on a touch screen still marks. Default true. */
markMomentEnabled: boolean;
}
```
### FeedbackContext
```ts
/** Where the player is in the game, for their feedback ({@link Page.setFeedbackContext}): up to 8 short facts. */
type FeedbackContext = Record<string, string | number | boolean>;
```
### CoveredBy
```ts
/** What of Zaisma's covers the game ({@link page}): one of its sheets, one of its cards, or nothing. */
type CoveredBy = "sheet" | "card" | null;
```
### Versions
```ts
/** A version published "now" ({@link versions}). */
interface Versions {
/** Listen for "update". A wrong name fails with error.code "unknown_event". */
on(event: "update", listener: (update: PendingUpdate) => void): Versions;
off(event: "update", listener: (update: PendingUpdate) => void): Versions;
}
```
### PendingUpdate
```ts
/** A newer version is out ({@link versions}): apply() reloads the game at it, keeping the save. */
interface PendingUpdate {
/** The new version, like "version_k2v9q4x7m1p3w8r5t6y0". */
versionId: string;
apply(): void;
}
```
### Saves
```ts
/** The player's cloud saves ({@link saves}). */
interface Saves {
/**
* Listen for an event (the {@link SavesEvents}). A wrong name fails with error.code "unknown_event".
* Listen as the game starts: a conflict settled while the game was opening waits for the game to
* listen, then arrives at once.
*
* @example
* Zaisma.saves.on("conflict", (conflict) => {});
* Zaisma.saves.on("developerChange", (change) => {});
*/
on<EventName extends keyof SavesEvents>(event: EventName, listener: SavesEvents[EventName]): this;
/** Stop listening. */
off<EventName extends keyof SavesEvents>(event: EventName, listener: SavesEvents[EventName]): this;
/**
* The player's earlier versions in this game, newest first: up to 5, with the one the save is now
* marked isCurrentSave. Each says why it was kept ({@link SaveCopyReason}).
*
* @example
* const { saveCopies } = await Zaisma.saves.listCopies();
* for (const copy of saveCopies) addRow(new Date(copy.savedAt).toLocaleString(), copy.copyReason);
*/
listCopies(): Promise<SaveCopyList>;
/**
* One earlier version with what it holds: its localStorage items and IndexedDB databases, so the game
* can show what's in it ("Level 7, 1,200 coins"). Writing its localStorageItems into localStorage
* puts that progress in place without a reload, and the next save copies it to the account, but
* keeps no earlier version of the progress it replaced: {@link Saves.restoreCopy} does. Fails with
* error.code "bad_save_copy_id" for anything that isn't a save copy ID, and "no_save_copy" when the
* player has no such copy (copies past the newest 5 are gone).
*
* @example
* const copy = await Zaisma.saves.getCopy(copyId);
* levelText.textContent = "Level " + (copy.localStorageItems.level ?? "1");
*/
getCopy(saveCopyId: string): Promise<SaveCopyContents>;
/**
* Make an earlier version the player's save again, as the player's own change. The save it replaces
* is kept first as an earlier version (copyReason "restore"), so going back can be undone. It
* reloads the game with the restored progress, the way a game that keeps its state in memory needs:
* resolves just before the reload. Fails with error.code "bad_save_copy_id", "no_save_copy" and the
* errors every saves call has.
*
* @example
* useOtherButton.onclick = () => Zaisma.saves.restoreCopy(conflict.keptSaveCopy.id);
*/
restoreCopy(saveCopyId: string): Promise<void>;
}
```
### SavesEvents
```ts
/** The events of {@link saves}, each with what its listener gets. */
interface SavesEvents {
/**
* Two progresses differed (two devices, or a guest who signed in to an account with progress of its
* own), and Zaisma settled it: the progress played most recently won and is what the game opened
* with, and the other was kept as an earlier version. Offer the player the other one if you like.
* It fires on the device whose save was kept or refused, where the choice happened, never on a
* device that only takes up newer progress (like coming back to a tab after another device played
* on): that device's earlier save is still in {@link Saves.listCopies}.
*
* @example
* Zaisma.saves.on("conflict", async (conflict) => {
* const other = await Zaisma.saves.getCopy(conflict.keptSaveCopy.id);
* const where = conflict.winnerKind === "this_device" ? "another device" : "this device";
* if (confirm("Use your progress from " + where + " instead (level " + other.localStorageItems.level + ")?")) {
* await Zaisma.saves.restoreCopy(conflict.keptSaveCopy.id); // the game reloads with it
* }
* });
*/
conflict: (conflict: SaveConflict) => void;
/**
* You changed the player's save through the API or MCP while they played. Listening means the game
* takes it in place: Zaisma has already written it into the game's localStorage and IndexedDB, so
* reread your state from there (without listening, the game reloads instead). The player's progress
* since their last save is kept as an earlier version.
*
* @example
* Zaisma.saves.on("developerChange", () => {
* state.coins = Number(localStorage.getItem("coins") ?? 0);
* state.level = Number(localStorage.getItem("level") ?? 1);
* redraw();
* });
*/
developerChange: (change: DeveloperChange) => void;
}
```
### SaveCopyList
```ts
/** The player's earlier versions ({@link Saves.listCopies}). */
interface SaveCopyList {
/** Newest first: up to 5. */
saveCopies: SaveCopy[];
}
```
### SaveCopy
```ts
/** One of the player's earlier versions ({@link Saves.listCopies}). */
interface SaveCopy {
/** Its ID, like "save_copy_k2v9q4x7m1p3w8r5t6y0": what getCopy and restoreCopy take. */
id: string;
/** When this progress was saved, as an ISO time in UTC. */
savedAt: string;
/** Why it was kept. */
copyReason: SaveCopyReason;
/** How big it is, in bytes. */
sizeBytes: number;
/** It's the same progress as the save now. */
isCurrentSave: boolean;
/**
* The game version that saved it, like "version_k2v9q4x7m1p3w8r5t6y0", as the game's page reported it;
* null for a save you changed, replaced or reset through the API or MCP, and for one from before Zaisma kept it;
* a restored save has the restored copy's.
*/
versionId: string | null;
}
```
### SaveCopyContents
```ts
/** An earlier version with what it holds ({@link Saves.getCopy}). */
interface SaveCopyContents extends SaveCopy {
/** The game's localStorage as it was: every key with its text. */
localStorageItems: Record<string, string>;
/**
* The game's IndexedDB databases as it was ([] when it keeps none), in Zaisma's save format, with
* records whose binary data and dates are tagged values. restoreCopy puts them back.
*/
indexeddbDatabases: IndexeddbDatabase[];
}
```
### IndexeddbDatabase
```ts
/**
* One IndexedDB database in a save, in Zaisma's save format, the same as the developer API's
* get_save_copy answers. Its names (keyPath, autoIncrement, unique, multiEntry, version) are IndexedDB's own.
*/
interface IndexeddbDatabase {
name: string;
/** The database's IndexedDB version: a whole number from 1. */
version: number;
stores: IndexeddbStore[];
}
```
### IndexeddbStore
```ts
/** One object store in an {@link IndexeddbDatabase}. */
interface IndexeddbStore {
name: string;
/** Where each record's key is in its value, or null when keys are kept beside the values. */
keyPath: string | string[] | null;
autoIncrement: boolean;
indexes: IndexeddbIndex[];
/** Each record as [key, value], in Zaisma's save format: binary data, dates and the like are tagged values. */
records: [unknown, unknown][];
}
```
### IndexeddbIndex
```ts
/** One index on an {@link IndexeddbStore}. */
interface IndexeddbIndex {
name: string;
keyPath: string | string[];
unique: boolean;
multiEntry: boolean;
}
```
### SaveCopyReason
```ts
/**
* Why an earlier version was kept: hourly (a routine copy while playing, at most one an hour),
* account_lost (the account's progress, replaced by a device's played more recently), smaller (the
* save shrank to under half, usually a reset), restore (the player went back to an earlier version:
* restoreCopy), device_lost (a device's progress lost to the account's, played more recently) or
* developer (you changed, reset or restored the save through the API or MCP).
* More values may come; treat an unknown one as no reason shown.
*/
type SaveCopyReason = "hourly" | "account_lost" | "smaller" | "restore" | "device_lost" | "developer";
```
### SaveConflict
```ts
/** A conflict Zaisma settled ({@link SavesEvents.conflict}). */
interface SaveConflict {
/**
* Whose progress won: "this_device", played more recently, or "account", the account's, which the game
* opened with. More values may come; treat an unknown one as "account".
*/
winnerKind: "this_device" | "account";
/** Where the other progress is kept. */
keptSaveCopy: SaveCopy;
}
```
### DeveloperChange
```ts
/** A change you made to the player's save ({@link SavesEvents.developerChange}). */
interface DeveloperChange {
/** When you changed it, as an ISO time in UTC. */
savedAt: string;
/** Where the player's progress since their last save is kept, or null when there was none to keep. */
keptSaveCopy: SaveCopy | null;
}
```
### LinkOptions
```ts
/** What {@link Links.open} takes. Every option is optional. */
interface LinkOptions {
/** A path added under the link's address: starts with /, like "/buy", with no ?, #, . or .. parts. Up to 500 characters. */
path?: string;
/**
* Query parameters added to the link's address, like { item: "sword", player: "player_8f3k2m" }:
* up to 20, each text of up to 500 characters (numbers as String(3)). Never one the link's own address sets.
* The whole opened address is at most 2,000 characters and each parameter name at most 100.
*/
queryParameters?: Record<string, string>;
/**
* The link's whole address when the game runs on your own site, like "https://kit.itch.io/sky-hopper",
* where it opens straight away. On Zaisma the address registered for the link opens instead, so keep the two the same.
*/
ownSiteUrl?: string;
}
```
### LinkStatus
```ts
/**
* What happened when the game opened a link: opened (in a new tab), or stayed (the player chose Stay, or
* the link can't open for them). More values may come; treat an unknown one as "stayed".
*/
type LinkStatus = "opened" | "stayed";
```
### JoinOptions
```ts
/** What {@link joinRoom} takes. Every option is optional. */
interface JoinOptions {
/**
* A room's code, like "K7Q2MX": six characters today; they may grow up to 12, so don't depend on the
* length. By default, the code in the page's link (?room=), else a new room.
*/
roomCode?: string;
/**
* Your own game server's full address, like "wss://play.example.com" (wss://, ws://, https:// or
* http://), instead of Zaisma rooms. Add it to the game's own servers on Zaisma first, so the game
* is allowed to connect to it.
*/
serverUrl?: string;
/**
* How to reach a room on your own server (serverUrl, wss:// or https://): "websocket" (the default), or
* "webtransport", the fast lane: WebTransport, where sends with delivery "latest_only" go as datagrams, so a
* late one is dropped instead of holding up what comes after it, as PC shooters play. Your server has to
* serve it (the Node runner's --webtransport-port). Where WebTransport isn't there or doesn't connect in
* 3 seconds (a network that blocks UDP), the room uses the WebSocket by itself; {@link Room.transport} says
* which. Zaisma rooms use the WebSocket either way. Anything else is refused with error.code "bad_transport".
*
* @example
* const room = await Zaisma.joinRoom({ serverUrl: "wss://play.example.com", transport: "webtransport" });
*/
transport?: "websocket" | "webtransport";
/**
* true: a new room that shows in room lists, for others to find. By default false: a room only its
* code and link reach, like a private match ({@link Rooms.quickJoin} lists its new rooms unless given
* false). Counts only when this player makes the room.
*/
isListed?: boolean;
/**
* false: a new room friends can't Join from Zaisma, shown grayed as "Private room" (codes and links
* still work). Counts only when this player makes the room.
*/
friendJoinsEnabled?: boolean;
/** A new room's name, like "Ana's castle": up to 40 characters. Counts only when this player makes the room. */
name?: string;
/**
* A new room's labels, which players can filter rooms by, like { Mode: "Classic", Map: "Docks" }: up
* to 4, names up to 16 characters and values up to 24. Counts only when this player makes the room.
*/
labels?: Record<string, string>;
/**
* What the player brings into the room, for the game server's canJoin and onJoin, like the character
* they picked: plain JSON, up to 4 KB. It comes from the player's browser, so check it like any message.
*/
joinData?: unknown;
/**
* Seconds without input before the player is asked "Still there?", from 30 to 86400 (anything else is
* refused with error.code "bad_idle_timeout"). By default, the game server's idleTimeoutSec (600, 10 minutes).
*/
idleTimeoutSec?: number;
/**
* false: never ask "Still there?" in this game. The room's own check still applies, except where the
* game server's idleCheck is "client", as with the relay.
*/
idleCheckEnabled?: boolean;
/**
* true: watch the room instead of playing, where the game server takes spectators (its
* maximumSpectatorCount). A spectator gets what the room sends everyone, sends nothing ({@link Room.send}
* throws error.code "spectator_cannot_send"), doesn't count as playing and is never asked "Still there?".
* A closed or full room can still be watched; a room with nobody playing can't (error.code "room_not_running"),
* and nor can one whose spectators are all there (error.code "spectators_full"), and a player already
* playing in it can't watch it too (error.code "already_playing"). Zaisma's Watch opens
* the game with {@link Rooms.isLinkedAsSpectator} true.
*
* @example
* const room = await Zaisma.joinRoom({ isSpectator: Zaisma.rooms.isLinkedAsSpectator });
*/
isSpectator?: boolean; /**
* true (the default): what the game sends at once (in one frame of its loop, say) goes to the room as one
* message of up to 8, and sends keep under the room's 30 a second by themselves: past that, they wait a few
* milliseconds and go together instead of coming back "too_fast". Each still reaches the game server's
* onMessage on its own, in order. A room is billed for each message it gets, so this costs the game less.
* Rooms on your own server combine only when their game server says it can (game server 1.40 and later).
* false: every send goes alone and at once, as it's made.
*/
sendCombiningEnabled?: boolean;
/**
* true (the default): a { delivery: "latest_only" } send that's the same as the last one with its latestKey
* isn't sent, since the room already has it; the first after a reconnect always goes. Reliable sends always go.
* false: send every one, as when the game server expects a steady stream.
*/
unchangedSkippingEnabled?: boolean;
}
```
### Region
```ts
/**
* A continent code: Africa, Antarctica, Asia, Europe, North America, Oceania, South America. A region
* the SDK doesn't take is refused with error.code "bad_region".
*/
type Region = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
```
### QuickJoinOptions
```ts
/**
* What {@link Rooms.quickJoin} takes: joinRoom's options but roomCode, isSpectator, serverUrl and transport
* (it finds Zaisma rooms), and region.
*/
interface QuickJoinOptions extends Omit<JoinOptions, "roomCode" | "isSpectator" | "serverUrl" | "transport"> {
/** Look for a room in this region only, like "EU", as in {@link RoomList.regions}. */
region?: Region;
/** Look for a room with these labels, like { Mode: "Classic" }; a new room gets them. */
labels?: Record<string, string>;
}
```
### ListOptions
```ts
/** What {@link Rooms.list} takes. */
interface ListOptions {
/** Rooms in this region only, like "EU", as in {@link RoomList.regions}. */
region?: Region;
/** Rooms with these labels only, like { Mode: "Classic" }. */
labels?: Record<string, string>;
}
```
### MoveJoinOptions
```ts
/** What {@link Move.join} takes: joinRoom's options but roomCode, serverUrl and transport, which are the move's own, and isSpectator (moves are for players). */
interface MoveJoinOptions extends Omit<JoinOptions, "roomCode" | "serverUrl" | "transport" | "isSpectator"> {}
```
### KickOptions
```ts
/** What {@link Room.kick} takes. */
interface KickOptions {
/** Keep them out for the rest of the match. */
keepOut?: boolean;
}
```
### RoomInfo
```ts
/** What {@link Room.setInfo} takes. Leave a field out to keep it; null clears it. */
interface RoomInfo {
/** The room's name, like "Ana's castle": up to 40 characters. */
name?: string | null;
/** The room's labels, like { Mode: "Classic", Map: "Docks" }: up to 4, names up to 16 characters and values up to 24. */
labels?: Record<string, string> | null;
}
```
### Rooms
```ts
/** Room browsing: the game's listed rooms, which show on its Zaisma page and to the game itself. */
interface Rooms {
/**
* The room code the player's link points to (?room=CODE), or null. Check it to show a menu or a
* character picker first, then join with what the player picked: joinRoom and quickJoin both follow a link to a Zaisma room.
*/
readonly linkedRoomCode: string | null;
/**
* The game's own server the player's link points to (?server=, beside ?room=), or null: a friend's
* Join into a room on your own servers ({@link Friends.setRoom}). Only joinRoom({ serverUrl }) follows a
* link that names a server (the same one); quickJoin follows only links to Zaisma rooms, which name none. A game on
* its own servers joins with joinRoom({ serverUrl, roomCode: Zaisma.rooms.linkedRoomCode }), using this
* as serverUrl. Zaisma passes it on only when it's one of the game's own servers (own_server_urls).
*/
readonly linkedServerUrl: string | null;
/**
* true when the player's link is a Watch (?watch=1 beside ?room=), from Zaisma's Watch beside Join: they
* came to watch the linked room, not to play. Join it with joinRoom({ isSpectator: true }).
*/
readonly isLinkedAsSpectator: boolean;
/**
* The game's listed rooms on Zaisma, for a game's own lobby or server browser: rooms with space
* first (the player's country, then region, then the busiest), up to 50. Never who's in them.
* Fails with error.code "not_on_zaisma" in a game that isn't hosted on Zaisma.
*
* @example
* const { rooms, playingPlayerCount, regions } = await Zaisma.rooms.list();
* Zaisma.rooms.list({ region: "EU", labels: { Mode: "Classic" } }); // one region, or rooms with these labels
*/
list(listOptions?: ListOptions): Promise<RoomList>;
/**
* Drop the player into a match: the room their link points to if it has space, otherwise a listed
* room with space (nearby and busy first), otherwise a new room. Rooms with someone the player
* blocked come after the others, and before a new room; the linked room is the player's own choice.
*
* @example
* const room = await Zaisma.rooms.quickJoin();
* Zaisma.rooms.quickJoin({ region: "EU", labels: { Mode: "Classic" } }); // a room like that with space, else a new one with those labels
*/
quickJoin(quickJoinOptions?: QuickJoinOptions): Promise<Room>;
}
```
### Server
```ts
/** The game's own game server outside any room ({@link server}). */
interface Server {
/**
* Send a request to the game's own game server, its onRequest(player, request, server), outside
* any room, and get back what it answers: for a leaderboard, a shop or a daily reward, in
* single-player games too. The player's pass goes with it, so the server knows who's asking and
* the player can't pretend to be someone else. The request is plain JSON, up to 16 KB; say what
* it's for in its type, like a room message. On Zaisma, the game server is the one in your
* upload's zaisma-server/ folder (or zaisma-server.js); give serverUrl for your own.
*
* Fails with error.code: no_request_handler (the game server has no onRequest), game_server_error
* (onRequest threw, answered something that isn't plain JSON or over 1 MB, or took over 10
* seconds; you see why with the game server's errors), hosting_paused (the game's hosting
* on Zaisma is paused this month: its free allowance or its developer's budget or credit is used), too_big, bad_request (not plain JSON), slow_down
* (over about 120 a minute from one address), bad_pass, account_needed, unchecked,
* game_unavailable, bad_origin, busy, bad_server_url, not_on_zaisma (the game is played off
* Zaisma without a serverUrl, or before {@link Zaisma.setUpOffZaisma}), bad_player_token (off Zaisma,
* your server didn't take the playerToken), unknown_option and request_failed.
*
* @example
* const top = await Zaisma.server.request({ type: "leaderboard" });
* const { coinCount } = await Zaisma.server.request({ type: "claimDailyReward" });
* Zaisma.server.request({ type: "buy", itemId: "sword" }, { serverUrl: "https://play.example.com" }); // your own server
*/
request(request: unknown, requestOptions?: RequestOptions): Promise<unknown>;
}
```
### SendOptions
```ts
/** How {@link Room.send} and {@link Room.sendBytes} send. */
interface SendOptions {
/**
* "reliable" (the default) reaches the game server in order. "latest_only" may be dropped: while
* this player's connection is backed up, a newer send with the same latestKey replaces it, and the
* newest goes once it catches up. For input sent every frame, like where the player aims. On the fast
* lane to your own server ({@link JoinOptions.transport}), it goes as a datagram when it fits one. Anything
* else throws error.code "bad_send_option".
*/
delivery?: "reliable" | "latest_only";
/**
* For "latest_only", and needed there: which sends replace each other, up to 40 characters, like
* "position". latest_only without one throws error.code "bad_send_option".
*/
latestKey?: string;
}
```
### StateChange
```ts
/**
* One change in a state update: [path, value] sets what's at path to value, [path] removes it, and an
* empty path replaces the whole state. path is keys of objects and indexes of arrays, from the top.
*/
type StateChange = [path: (string | number)[]] | [path: (string | number)[], value: unknown];
```
### RequestOptions
```ts
/** Options for {@link Server.request}. */
interface RequestOptions {
/** Your own game server's address, like "https://play.example.com", instead of Zaisma's. The Node runner answers requests on the same port as its rooms. */
serverUrl?: string;
}
```
### Room
```ts
/** A room the player is in: one live match, running one copy of the game server. */
interface Room {
/**
* The room's code, like "K7Q2MX": six characters today; they may grow up to 12, so don't depend on the
* length. It changes when the game server moves the player (the "moved" event).
*/
readonly roomCode: string;
/** This player. */
readonly me: Player;
/**
* Players in the room right now, in join order, this player included, each with why they aren't
* playing (awayReason), like a player whose connection dropped and who has a few seconds to come back.
*/
readonly players: readonly ListedPlayer[];
/** The host's player ID, when the game server gives the host controls (the relay does), else null. */
readonly hostPlayerId: string | null;
/** This player is watching, not playing ({@link JoinOptions.isSpectator}): they're never in players. */
readonly isSpectator: boolean;
/** How many are watching the room; the "settings" event says when it changes. */
readonly spectatorCount: number;
/** Where the socket stands; the "connectionStatus" event says when it changes. Away is awayReason, not this. */
readonly connectionStatus: ConnectionStatus;
/**
* What this connection uses now: "webtransport" on the fast lane to your own server
* ({@link JoinOptions.transport}), else "websocket", including when the fast lane didn't connect.
*/
readonly transport: "websocket" | "webtransport";
/**
* Why this player is out of the match: "idle" (no input until the "Still there?" ran out) or "hidden"
* (the game hidden too long), from the "away" event until "back"; null while they play.
*/
readonly awayReason: "idle" | "hidden" | null;
/**
* The room's link on Zaisma, like "https://zaisma.com/g/sky-hopper?room=K7Q2MX", with &server= for a
* room on your own server, or null outside Zaisma.
*/
readonly inviteUrl: string | null;
/** Shown in room lists. A room that isn't still works by code and link. */
readonly isListed: boolean;
/** Taking new players. A closed room lets back only players who were in it. */
readonly isOpen: boolean;
/** Zaisma's Join (friends on zaisma.com, Zaisma.friends) offers this room; when false it's grayed as "Private room". */
readonly friendJoinsEnabled: boolean;
/** The room's name, like "Ana's castle", or null. */
readonly name: string | null;
/** The room's labels, like { Mode: "Classic", Map: "Docks" }. */
readonly labels: Readonly<Record<string, string>>;
/**
* Whether this player can chat at all ({@link Room.chat}): a Zaisma account whose chat setting isn't
* nobody, playing (not watching). False for guests: hide your chat box, and offer preset phrases or emotes.
*/
readonly canChat: boolean;
/**
* Whether this player can talk in voice ({@link Room.voice}): a Zaisma account whose voice setting reaches someone,
* playing (not watching). A player who can't talk can still join voice to listen.
*/
readonly canTalk: boolean;
/**
* Voice in this room: your game holds the microphone, and Zaisma's room decides whose voices reach this player, by
* chat's rules (who each player lets hear them, blocks, mutes, and anyone under 18 only where two independent
* players hear them too), plus your server's teams and ranges (room.setVoiceGroup, setHeardSpeakers). It goes
* through Cloudflare's media server, so nobody sees anyone's address, and it's on your game's meter as voice.
* Each player hears up to 16 voices at once (your server can set 1 to 32), the loudest past that.
* @example
* await room.voice.join();
* room.on("speaking", ({ playerId, isSpeaking }) => showMicIcon(playerId, isSpeaking));
* // Proximity voice: fade and place each voice by distance.
* for (const other of room.players) room.voice.setSpeakerVolume(other.id, volumeByDistance(other));
*/
readonly voice: RoomVoice;
/**
* When Zaisma will end this match, an ISO time, or null: set once the game's hosting pauses for the
* month, an hour after the pause (the "ending" event); null again if Zaisma calls the end off (the
* "endingCancelled" event). Never set in a room on your own server.
*/
readonly endsAt: string | null;
/**
* This player's round trip to the room in milliseconds, smoothed and measured by the room; null until
* the first measurement, right after joining. The game server reads the same number with
* room.pingDurationMs(playerId).
*
* @example
* // A ping readout in the corner
* pingText.textContent = room.pingDurationMs === null ? "" : room.pingDurationMs + " ms";
*/
readonly pingDurationMs: number | null;
/**
* This player's view of the game server's state, when it has stateSyncEnabled: the game server's
* state, or what its stateView answers for this player. null until the first update, which comes as
* the player joins; after that it changes with each update (the "state" event). Read it, don't change it.
*
* @example
* function draw() {
* const world = room.state;
* if (world) for (const [id, body] of Object.entries(world.bodies)) drawBody(id, body);
* requestAnimationFrame(draw);
* }
*/
readonly state: unknown | null;
/**
* The state as it was smoothingOptions.delayMs behind the room's clock (100 unless you say, up to 1000),
* between the two updates around then: numbers blended in a straight line (integers in between come back
* as fractions), anything else as the older update had it, and what's in only one of them as it is. So
* positions move evenly however the updates arrive, a moment behind; an angle that wraps around blends
* the long way, so blend those yourself. A copy, yours to keep; null until the first update. Anything else
* for delayMs throws error.code "bad_delay", and other options "unknown_option". Predicting this player's
* own moves stays your game's.
*
* @example
* function draw() {
* const world = room.smoothedState(); // or room.smoothedState({ delayMs: 150 })
* if (world) for (const body of Object.values(world.bodies)) drawBody(body.x, body.y);
* requestAnimationFrame(draw);
* }
*/
smoothedState(smoothingOptions?: SmoothingOptions): unknown | null;
/**
* The room's clock now, in epoch milliseconds, estimated from the room's probes (Date.now() until the
* first one): the same clock as the game server's room.serverTimeMs(), so a time it sends means the
* same moment for every player.
*
* @example
* // The game server sent { type: "countdown", startsAtMs: room.serverTimeMs() + 3000 }
* room.on("message", (message) => {
* if (message.type === "countdown") startsInMs = message.startsAtMs - room.serverTimeMs();
* });
*/
serverTimeMs(): number;
/**
* Send a message to the game server: plain JSON, up to 16 KB (more throws error.code "too_big"), about
* 30 a second at most. Send input when it changes, not every frame. While connectionStatus isn't "open"
* or the player is away, reliable sends wait and go in order once the room is back, up to 60: past that
* the oldest is dropped, and an "error" event says "send_queue_full" once. With
* { delivery: "latest_only", latestKey }, a message may be dropped for a newer one (SendOptions), and one
* the same as the last with its latestKey isn't sent (JoinOptions.unchangedSkippingEnabled). What the game
* sends at once goes as one message (JoinOptions.sendCombiningEnabled). A
* spectator can't send: it throws error.code "spectator_cannot_send". Returns false only when the room
* is gone (ended, kicked or left), so nothing will ever send.
*
* @example
* room.send({ type: "fire" });
* // Where the player aims, as it changes: only the newest matters.
* room.send({ type: "aim", angle }, { delivery: "latest_only", latestKey: "aim" });
*/
send(message: unknown, sendOptions?: SendOptions): boolean;
/**
* Send bytes to the game server (its onBytes), like a compact input: an ArrayBuffer or any typed
* array, up to 16 KB (more throws error.code "too_big"), counted with messages (about 30 a second at
* most). Anything else throws error.code "bad_bytes", and a spectator's throws "spectator_cannot_send".
* Waits like room.send while the room isn't reachable, takes the same sendOptions, and returns false
* only when the room is gone.
*/
sendBytes(bytes: ArrayBuffer | ArrayBufferView, sendOptions?: SendOptions): boolean;
/** Leave the room for good. */
leave(): void;
/**
* Show or hide the room in room lists. From the room's host when the game uses the relay; with a
* game server of your own, the server decides (its room.setListed). The "settings" event says when it changed.
*/
setListed(isListed: boolean): void;
/**
* Open or close the room to new players; players who were in it can still come back. From the
* room's host when the game uses the relay; with a game server of your own, the server decides (its
* room.setOpen). The "settings" event says when it changed.
*/
setOpen(isOpen: boolean): void;
/**
* Turn Zaisma's Join on or off for this room: off, a player's friends see Join grayed as "Private
* room" on zaisma.com and in {@link Friends.list}. It isn't a lock: a code or link still reaches the
* room, so close it (setOpen) or answer false from canJoin to keep players out. From the room's host
* when the game uses the relay; with a game server of your own, the server decides (its
* room.setFriendJoinsEnabled). The "settings" event says when it changed.
*/
setFriendJoinsEnabled(isEnabled: boolean): void;
/**
* Name and label the room. From the room's host when the game uses the relay; with a game server of
* your own, the server decides (its room.setInfo). Names and labels players type show on Zaisma's
* pages only if they pass Zaisma's filter for its pages, which blocks swearing too.
*/
setInfo(nameAndLabels: RoomInfo): void;
/**
* The host removes a player, when the game server gives the host controls (the relay does). They're
* told the host removed them; keepOut keeps them out for the rest of the match.
*/
kick(playerId: string, kickOptions?: KickOptions): void;
/**
* Whether to hide a player's emotes and phrases: this player muted or blocked them, or there's a
* block between them either way (never which one made it, so a blocked player is never told).
*/
isMuted(playerId: string): boolean;
/** Mute a player for this room. The "muted" event says the list changed. */
mute(playerId: string): void;
/** Unmute a player muted for this room. A block stays: {@link Room.unblock} lifts one. */
unmute(playerId: string): void;
/**
* Lift a block this session made of a player. A block between two accounts is undone only on
* zaisma.com/friends, never from a game.
*/
unblock(playerId: string): void;
/**
* Block a player in the room: a wall both ways, so neither one's emotes and phrases reach the other,
* and the game server's room.hasBlockBetween says so. When both are Zaisma accounts, Zaisma asks the
* player beside the game first, and the block then lasts in every game until they undo it on
* zaisma.com/friends; it ends a friendship, and the blocked player isn't told. Any other block (a
* guest's, or of a guest) lasts for the session. Resolves true once they're blocked, or false if the
* player changed their mind. A block never removes anyone from the room.
*/
block(playerId: string): Promise<boolean>;
/**
* Report a player to Zaisma, with what happened in the player's own words if they gave any (details).
* On Zaisma it opens Zaisma's report sheet beside the game, filled in with the player, reason and words,
* where the player picks the messages to send and sends it: only reports a player sends there count
* toward muting someone. Resolves once they send it; rejects with error.code "report_not_sent" when they
* close it without sending. Off Zaisma (a game's own site) the last chat lines (up to 20) they sent this
* player, or this player sent them, go with it; nothing else about the reporting player is sent.
*/
report(playerId: string, reason: ReportReason, details?: string): Promise<ReportAnswer>;
/**
* Send a chat message: through the room to the players in it (or chatOptions.toPlayerIds of them) who
* may chat with this player, on Zaisma's rooms or your own server's runner. It reaches only players in
* this player's chat group whose settings let them chat with this player, never anyone with a block
* between them, and never spectators. Your game server's onChat may stop it or send it to fewer
* players first; then Zaisma's chat filter checks it on its way (messages to and from under-18s
* always, between adults when your game server turns it on), and Zaisma keeps none of it. Draw the
* chat yourself: the "chat" event brings the others' messages; show this player's own when it resolves.
*
* Resolves { sentAt } once it went, even when nobody could read it (the sender is never told who
* can't). Rejects with error.code chat_stopped (error.reason says why, like contact_details or
* stopped_by_game, and error.message is what to show the player), chat_not_allowed (a guest, or chat
* set to nobody: check {@link Room.canChat} first), chat_empty, chat_too_long (over 2000 characters),
* chat_too_fast (over 20 in 10 seconds) or connection_closed.
*
* @example
* room.chat(input.value).then(({ sentAt }) => addLine(room.me.name, input.value), (error) => showError(error.message));
*/
chat(text: string, chatOptions?: ChatOptions): Promise<ChatSent>;
/**
* Listen for an event. Listening is optional: without "move" and "back" listeners, the SDK follows
* a move and rejoins by itself; with one, your game decides when.
*
* @example
* room.on("message", (message) => {});
* room.on("players", (players) => {});
* room.on("move", (move) => { showLoading(); move.follow(); });
*/
on<EventName extends keyof RoomEvents>(event: EventName, listener: RoomEvents[EventName]): this;
/** Stop listening. */
off<EventName extends keyof RoomEvents>(event: EventName, listener: RoomEvents[EventName]): this;
}
```
### RoomEvents
```ts
/** A room's events, each with what its listener gets. */
interface RoomEvents {
/**
* A message from the game server: the game's own, as it sent it, and the player it came from when the
* game server passed one player's message on (its fromPlayerId; the relay always does), or null.
*/
message: (message: any, fromPlayerId: string | null) => void;
/**
* Bytes from the game server (its room.broadcastBytes or room.sendBytes): fromPlayerId is the player
* they came from when the game server passed one player's bytes on (the relay always does), or null.
*/
bytes: (bytes: Uint8Array, fromPlayerId: string | null) => void;
/**
* A state update, when the game server has stateSyncEnabled: state is room.state now, and changes
* what changed since the last update, or null after a full copy (as the player joins, and after their
* connection was backed up). Most games read room.state or room.smoothedState() as they draw instead.
* @example
* room.on("state", (state, changes) => { scoreText.textContent = String(state.scores[room.me.id]); });
*/
state: (state: any, changes: StateChange[] | null) => void;
/**
* Players joined, left, walked away or came back, or their connection dropped or came back; the same
* list as room.players.
* @example
* // Freeze a player whose connection dropped, and show them reconnecting, until they're back.
* room.on("players", (players) => {
* for (const player of players) {
* const body = bodies.get(player.id);
* if (body) body.isFrozen = player.awayReason === "lost";
* }
* });
*/
players: (players: readonly ListedPlayer[]) => void;
/** Where the socket stands, as room.connectionStatus. */
connectionStatus: (connectionStatus: ConnectionStatus) => void;
/** The match ended, with its message and why (endReason). The connection closes. */
ended: (ended: Ended) => void;
/**
* Zaisma will end this match at endsAt (an ISO time, also room.endsAt), because the game's hosting on
* Zaisma rooms paused for the month: tell your players and save what should last.
* "ended" follows then.
*/
ending: (ending: Ending) => void;
/**
* Zaisma called off the end the "ending" event announced, because the game's hosting started again:
* room.endsAt is null, and the match goes on. Optional, as events added after v1 are, so v1's types still fit.
*/
endingCancelled?: () => void;
/** The game server or the host removed the player from the room. The connection closes. */
kicked: (kicked: Kicked) => void;
/** The room's listing, Join switch, name or labels changed, or how many watch: room.isListed, room.isOpen, room.friendJoinsEnabled, room.name, room.labels and room.spectatorCount have the new ones. */
settings: (settings: RoomSettingsChange) => void;
/**
* The game server is sending the player to another room (its room.reserve or room.moveTo). Without
* a listener the room follows by itself; with one, call move.follow() when your game is ready, or
* leave and move.join() it as a new room object.
*
* It also comes when the player, already playing, picks another room of this game on Zaisma's page
* (a friend's Join, an invite), with isAskedByPlayer true: the game switches rooms in place instead
* of reloading. Without a "move" listener, a room with a "moved" listener follows by itself; a room
* with neither, or a player switching between playing and watching, gets the game reloaded into the
* new room, as on a first visit.
*/
move: (move: Move) => void;
/** This room object moved to another room: same object, new code. A "players" event with the new list follows. */
moved: (moved: Moved) => void;
/**
* "Still there?": idleStatus "asking" when it's time to ask, after idleTimeoutSec without input, with
* answerTimeoutSec to answer. Listening replaces Zaisma's own "Still there?": a card beside the game
* on its zaisma.com page, and elsewhere a small plate in the game (restyle the plate with CSS on
* #zaisma-still-there instead, if you like). Then "answered" (any input), or "timed_out" as the room
* is told they walked away.
*/
idle: (idle: Idle) => void;
/**
* The player walked away: out of the match, with their seat held for seatHoldDurationSec, unless the
* game server decides (its onAway). Any input brings them back.
*/
away: (away: Away) => void;
/**
* The player came back after walking away. isSeatHeld true: they're in their held seat again, after
* the room let them back in. false: the seat ran out, and listening turns off rejoining by itself, so
* call back.rejoin() to rejoin their old room (it fails if the room is full or over).
*/
back: (back: Back) => void;
/** Whose emotes and phrases to hide changed: every player ID room.isMuted is true for. */
muted: (playerIds: string[]) => void;
/**
* The room sent an error, like too_fast, or the SDK has one for the room, like send_queue_full. Joining
* fails with the same code when the room won't take the player.
*/
error: (error: RoomError) => void;
/**
* The developer published a version with match_update_mode "now", and this match moves to it at
* versionUpdate.appliesAt at the latest (sooner if the game server switches at a good moment). Show a
* countdown or save; when it switches, this room object reconnects by itself, or, when the game's
* files changed (isReloading), the page reloads the game at the new version and joinRoom() with no
* code brings the player back into this room.
* @example
* room.on("versionUpdate", ({ appliesAt }) => showBanner(`Updating at ${new Date(appliesAt).toLocaleTimeString()}`));
*/
versionUpdate: (versionUpdate: VersionUpdate) => void;
/**
* A room message reached this room and its game server has no onRoomMessage, so every player's game hears
* it: from another room of the game (senderKind "room", fromRoomCode), its game server outside rooms
* ("server") or the developer (the API and MCP, "developer"), like an announcement or a live event starting.
* Zaisma shows nothing: your game decides. A game server with onRoomMessage takes it instead.
* @example
* room.on("roomMessage", ({ message }) => { if (message.kind === "blood_moon") startBloodMoon(); });
*/
roomMessage?: (roomMessage: RoomMessage) => void;
/**
* Another player's chat message reached this player ({@link Room.chat}). Messages from players this
* player muted or blocked never come. hasSwearing and hasSlur flag what Zaisma allows: hide or blur
* them if your game doesn't. (Optional here only so games written for v1's events still fit.)
*/
chat?: (chatMessage: ChatMessage) => void;
/** A voice started or stopped speaking, this player's own included, from its level on this device ({@link Room.voice}). */
speaking?: (speaking: Speaking) => void;
/** The voices this player hears changed: who's in {@link RoomVoice.speakerPlayerIds} now. */
voiceSpeakers?: (voiceSpeakers: { playerIds: string[] }) => void;
}
```
### Speaking
```ts
/** The "speaking" event's answer. */
interface Speaking {
playerId: string;
isSpeaking: boolean;
}
```
### VoiceOptions
```ts
/** What {@link RoomVoice.join} takes. */
interface VoiceOptions {
/** Join with the microphone muted (push-to-talk starts here). */
isMuted?: boolean;
/**
* For a room on your own server: a voice ticket your server signed (voiceTicket in @zaisma/game-server, with the
* game's ticket secret from create_ticket_secret), naming the voice channel and this player's team and range. Rooms
* on Zaisma need none.
*/
ticket?: string;
}
```
### RoomVoice
```ts
/** A room's voice: {@link Room.voice}. */
interface RoomVoice {
/**
* Join the room's voice: asks for the microphone when the player can talk ({@link Room.canTalk}), else joins to
* listen. Resolves once connected; rejects with microphone_refused (the player or browser said no, or the game's microphone_enabled
* setting is off), voice_not_allowed
* (a guest or a spectator), voice_unavailable or hosting_paused. Call it from a tap or key press: browsers play
* sound only after one.
*/
join(voiceOptions?: VoiceOptions): Promise<void>;
/** Leave voice: the microphone stops and nobody's voice comes. Leaving the room does it too. */
leave(): void;
/** On your own server: new rules for this player (a team switch, a range), as a new ticket from your server for the same channel. */
updateTicket(ticket: string): void;
/** Mute or unmute this player's microphone, for push-to-talk or a mute button. Muted, it sends almost nothing. */
setMicrophoneMuted(isMuted: boolean): void;
/** A voice's volume here, 0 to 100 (100 unless you set it), for proximity voice or a volume slider. At 0 it isn't sent at all. */
setSpeakerVolume(playerId: string, volumePct: number): void;
/** Where a voice sits left to right, -100 (left) to 100 (right), 0 unless you set it. */
setSpeakerPan(playerId: string, panPct: number): void;
/**
* A voice's sound after its volume, for your own effects (a radio's crackle, a muffled wall): disconnect it and
* connect it through your own nodes to {@link RoomVoice.outputNode}. Null while that voice isn't heard.
*/
audioNodeOf(playerId: string): AudioNode | null;
/** The Web Audio context voices play through, or null before joining. */
readonly audioContext: AudioContext | null;
/**
* Where voices go to the speakers, in {@link RoomVoice.audioContext}, or null before joining. Echo cancellation
* hears what plays through it, so the microphone doesn't send it back: connect your effects here, not to the
* context's destination, and your game's own sound too, made in this context, while players talk on speakers.
*/
readonly outputNode: AudioNode | null;
/** The players whose voices reach this player now (the "voiceSpeakers" event says when it changes). */
readonly speakerPlayerIds: readonly string[];
readonly isJoined: boolean;
/** Whether this player can talk, as {@link Room.canTalk}. */
readonly canTalk: boolean;
}
```
### ChatOptions
```ts
/** What {@link Room.chat} takes. */
interface ChatOptions {
/** Send it to only these players in the room (like a team), from room.players. All players when left out. */
toPlayerIds?: string[];
}
```
### ChatSent
```ts
/** {@link Room.chat}'s answer once the message went. */
interface ChatSent {
/** When the room sent it, as an ISO time. */
sentAt: string;
}
```
### ChatMessage
```ts
/** A chat message another player sent ({@link Room.chat}), as the "chat" event brings it. */
interface ChatMessage {
fromPlayerId: string;
text: string;
/** It swears: Zaisma allows it; hide it if your game doesn't. */
hasSwearing: boolean;
/** It has a slur: Zaisma allows it too; your game and its moderators decide. */
hasSlur: boolean;
/** When the room sent it, as an ISO time. */
sentAt: string;
}
```
### ChatErrorCode
```ts
/**
* The codes {@link Room.chat} rejects with: chat_stopped (the game server's onChat or Zaisma's filter
* stopped it: error.reason and error.message say why), chat_not_allowed, chat_empty, chat_too_long,
* chat_too_fast, bad_player_id, busy (try again in a moment), ended, spectator_cannot_send and
* connection_closed. More codes may come within v1: show the error's message.
*/
type ChatErrorCode = "chat_stopped" | "chat_not_allowed" | "chat_empty" | "chat_too_long" | "chat_too_fast" | "chat_not_here" | "bad_player_id" | "busy" | "ended" | "spectator_cannot_send" | "connection_closed";
```
### ChatStoppedReason
```ts
/**
* Why {@link Room.chat} was stopped (error.reason with chat_stopped): "stopped_by_game" (your game
* server's onChat), the filter's {@link ChatCheckReason}s, "chat_paused" (the sender's chat is paused
* for now) or "not_allowed_to_chat". More values may come.
*/
type ChatStoppedReason = "stopped_by_game" | ChatCheckReason | "chat_paused" | "not_allowed_to_chat";
```
### SmoothingOptions
```ts
/** What {@link Room.smoothedState} takes. */
interface SmoothingOptions {
/** How far behind the room's clock to draw, in milliseconds, from 0 to 1000. By default 100. */
delayMs?: number;
}
```
### EndReason
```ts
/** Why a match ended (the "ended" event). More may come within v1: treat one you don't know like "game". */
type EndReason = "game" | "no_players" | "hosting_paused" | "kept_room_deleted" | "game_unavailable" | "game_server_stopped";
```
### Ended
```ts
/** The match ended (the room's "ended" event). */
interface Ended {
/** What the game server said with room.end, or Zaisma's words when it ended the match; "" when none. */
message: string;
/**
* Why: "game" (the game server's room.end), "no_players" (a spectator's room emptied of players),
* "hosting_paused" (the game's hosting paused for the month), "kept_room_deleted" (the developer deleted
* the kept room), "game_unavailable" (the game was taken down or made private) or "game_server_stopped"
* (the game server failed and couldn't go on).
*/
endReason: EndReason;
}
```
### Ending
```ts
/** Zaisma will end the match (the room's "ending" event). */
interface Ending {
/** When, an ISO time, also room.endsAt. */
endsAt: string;
}
```
### Moved
```ts
/** This room object moved (the room's "moved" event). */
interface Moved {
/** The room it's in now. */
roomCode: string;
/** The room it left. */
fromRoomCode: string;
/** True when the player picked the room on Zaisma's page (a friend's Join, an invite), false when the game server moved them. */
isAskedByPlayer: boolean;
}
```
### Idle
```ts
/** The "Still there?" question (the room's "idle" event). */
interface Idle {
/** "asking": show the question. "answered": the player gave input. "timed_out": no answer, and the room hears they walked away. */
idleStatus: "asking" | "answered" | "timed_out";
/** How long the player has to answer, in seconds: 30. */
answerTimeoutSec: number;
}
```
### RoomMessage
```ts
/** A room message, as the room's "roomMessage" event hands it over. */
interface RoomMessage {
/** The message as sent: plain JSON, up to 16 KB. */
message: unknown;
/** Who sent it: another room's game server, the game server outside rooms, or the developer. */
senderKind: "room" | "server" | "developer";
/** The code of the room that sent it, or null unless senderKind is "room". */
fromRoomCode: string | null;
/** When it was sent, an ISO time. */
sentAt: string;
}
```
### VersionUpdate
```ts
/** A match moving to a version published "now" (the room's "versionUpdate" event). */
interface VersionUpdate {
/** The version it moves to, like "version_k2v9q4x7m1p3w8r5t6y0". */
versionId: string;
/** When it switches at the latest, an ISO time. */
appliesAt: string;
/** The game's own files changed, so the page reloads the game at the new version; false: it only reconnects. */
isReloading: boolean;
}
```
### Player
```ts
/** A player, as the room shows them to everyone. */
interface Player {
/** Their player ID, like "player_8f3k2m". An account's is the same in every game; a guest's is temporary. */
id: string;
/** The name shown for them: the account's name, or a guest's like "Swift Otter 42". */
name: string;
/** A signed-in Zaisma account, or a guest. */
kind: PlayerKind;
}
```
### ListedPlayer
```ts
/** A player in the room's list (room.players): who they are, and why they aren't playing. */
interface ListedPlayer extends Player {
/**
* Why this player isn't playing: "idle" or "hidden" (the game server kept them, onAway), or "lost"
* (their connection dropped and they have reconnectTimeoutSec to come back); null while they play.
*/
awayReason: "idle" | "hidden" | "lost" | null;
}
```
### PlayerKind
```ts
/**
* A signed-in Zaisma account, a guest, or a player your own server let in from outside Zaisma
* (outside_zaisma: a game played off Zaisma, {@link setUpOffZaisma}). More values may come; treat an unknown one as "guest".
*/
type PlayerKind = "guest" | "account" | "outside_zaisma";
```
### PlayerProfile
```ts
/** What anyone sees of an account on its profile, zaisma.com/@username ({@link player.getProfile}). */
interface PlayerProfile {
/** The account's player ID, the same in every game. */
id: string;
/** The name to show for them in games: their username, so nobody can pass as someone else. */
name: string;
/** Their username: unique ignoring case, 3 to 20 letters, numbers and underscores. It can change; the ID never does. */
username: string;
/** The name they chose to show beside @username on their profile, once checked; null when none. */
displayName: string | null;
/** What they wrote about themselves, once checked; null when none or when their profile is private. */
bio: string | null;
/** Links they chose to show (only adults can), up to 3; [] otherwise or when their profile is private. */
linkUrls: string[];
/** Their profile page. */
profileUrl: string;
/** True when they show their profile to friends only: strangers then see only the name, username and published games. */
isProfilePrivate: boolean;
/** Games they made that anyone can find, newest first. */
publishedGames: ProfileGame[];
/** Games they played lately, newest first, when they show those to anyone; [] otherwise. */
playedGames: (ProfileGame & { playedPeriod: PlayedPeriod })[];
/** The game they're playing right now, when they show that to anyone; null when they aren't, don't show it, appear offline, or the game isn't out yet. */
playingNow: ProfileGame | null;
}
```
### ProfileGame
```ts
/** A game on a profile. */
interface ProfileGame {
slug: string;
title: string;
/** The game's page on Zaisma. */
pageUrl: string;
}
```
### PlayedPeriod
```ts
/** Roughly when a player last played a game: a profile never shows a time. More values may come; treat an unknown one as "earlier". */
type PlayedPeriod = "today" | "this_week" | "this_month" | "earlier";
```
### PlayerWithPass
```ts
/** This tab's player and their player pass (Zaisma.player.getPass()). */
interface PlayerWithPass extends Player {
/**
* The player pass: a standard EdDSA JWT (header typ "pass+jwt") any server can check against the
* game's own keys at https://rooms.zaisma.com/v1/pass-keys/<gameSlug>. It proves only who the player is: its sub
* is the player's ID, kind says guest or account, aud is the game, pass_version_number is 1. A
* guest's pass also carries their name; an account's name comes from its profile
* (https://rooms.zaisma.com/v1/players/<id>). An account's pass says how its chat reaches:
* who_reads_my_chat (friends, my_age_band or everyone; nobody while its chat is stopped), chat_reading_enabled,
* an opaque chat_group_id (chat_group_…) that differs in every game, network_seal (its network, sealed for
* Zaisma's witness rule alone), and v1's who_can_chat as a stricter stand-in. Zaisma never tells a game anyone's
* age; a game could guess which chat group is the younger one from its size. It carries its friends and
* blocks, never as a list of players anyone can read: player_tag_id, its own opaque tag in this game
* (player_tag_…), friend_player_tag_ids, its friends' tags (up to 200), and block_player_tag_ids, the
* tags of the accounts it has a block with, either way (up to 100). Your own server checks it with
* verifyPass, then two players with passesAreFriends(first, second), canChat(first, second) before
* passing chat between them, and passesHaveBlockBetween(first, second) before matching them
* together, all from @zaisma/game-server; guests never chat and are never anyone's friend.
*/
pass: string;
/** When the pass runs out, as an ISO time in UTC. */
expiresAt: string;
}
```
### ConnectionStatus
```ts
/**
* Where a room's socket stands: "connecting" (joining, or rejoining after back.rejoin()), "open",
* "reconnecting" (it dropped and the SDK is connecting again) or "closed" (for good, or while the player
* is away with their seat gone or their connection dropped, until they're back). Whether the player is
* in the match is {@link Room.awayReason}, not this.
*/
type ConnectionStatus = "connecting" | "open" | "reconnecting" | "closed";
```
### RoomSettings
```ts
/** Whether a room shows in room lists, takes new players and is offered by Zaisma's Join, and its name and labels. */
interface RoomSettings {
isListed: boolean;
isOpen: boolean;
friendJoinsEnabled: boolean;
name: string | null;
labels: Record<string, string>;
}
```
### RoomSettingsChange
```ts
/** The room's settings changed, or how many watch (the room's "settings" event). */
interface RoomSettingsChange extends RoomSettings {
spectatorCount: number;
}
```
### Kicked
```ts
/** Why the player was removed from the room, and whether they're kept out for the rest of the match. */
interface Kicked {
/** Why, in words to show the player. */
message: string;
isKeptOut: boolean;
}
```
### Move
```ts
/** The game server is sending the player to another room ({@link RoomEvents.move}). */
interface Move {
/** The room they're being sent to. */
roomCode: string;
/**
* True when the player picked this room on Zaisma's page while playing (a friend's Join, an invite), false when the game
* server sent them. Ignoring a player's move leaves them where they are, so follow it unless the game can't leave now.
*/
isAskedByPlayer: boolean;
/** Move this room object there: the old connection closes and the new one opens. */
follow(): void;
/** Join it as a new room object instead, on the same server as this one: leave this one first. */
join(moveJoinOptions?: MoveJoinOptions): Promise<Room>;
}
```
### Away
```ts
/** The player walked away ({@link RoomEvents.away}). */
interface Away {
/** "idle": no input and no answer to "Still there?". "hidden": the game was hidden for 2 minutes in a real-time room. */
awayReason: "idle" | "hidden";
/** How long the room holds their seat, in seconds. */
seatHoldDurationSec: number;
}
```
### Back
```ts
/** The player is back after walking away ({@link RoomEvents.back}). */
interface Back {
/** Their room. */
roomCode: string;
/** true: they're in their held seat again, and rejoin does nothing. false: the seat ran out, so call rejoin. */
isSeatHeld: boolean;
/** Rejoin their old room when the seat ran out. Fails if it's full or over. */
rejoin(): void;
}
```
### RoomError
```ts
/** An error the room sent. */
interface RoomError {
code: RoomErrorCode;
/** What happened, in words. */
message: string;
}
```
### RoomErrorCode
```ts
/**
* The codes a room's errors have, in its "error" event and when joining fails:
* - room_full: the room has no space.
* - room_closed: the room is closed to new players.
* - ended: the match is over.
* - kept_out: the player was removed for the rest of the match.
* - refused: the game server's canJoin turned them away.
* - rented_share_used: this player is on a rented-server network, and the share of the game's hosting such traffic gets is used. Zaisma's page tells them to turn off their VPN or sign in. Everyone else plays on.
* - hosting_paused: the game's hosting on Zaisma is paused this month (its free allowance, or its developer's budget or credit, is used); new rooms open again when the month resets (UTC) or its developer adds credit, and a running match takes no new players and ends within the hour.
* - account_needed: the player is a guest, and the game needs a Zaisma account for multiplayer or the whole game.
* - game_not_open_to_player: the account is younger than the game's minimum age (set on the dashboard); the game never learns its age.
* - game_unavailable: the game can't be played right now.
* - bad_pass: the player pass wasn't accepted (the SDK gets a new one and tries once more).
* - bad_player_token: off Zaisma, your own server didn't take the playerToken ({@link setUpOffZaisma}); the game gets the player a new one.
* - bad_origin: the connection didn't come from the game's own page.
* - too_big: a message over 16 KB, or joinData over 4 KB.
* - too_fast: more messages than the room takes (about 30 a second).
* - bad_message, no_hello, not_allowed: a message the room couldn't read or use, didn't expect, or doesn't allow from this player.
* - busy: the room couldn't take the player right now; try again soon.
* - room_not_running: the room isn't running, like one with nobody playing to watch, or one a move named that isn't there.
* - blocked_player_here: quickJoin's first try at a room with someone the player blocked; quickJoin tries the others first, and you won't see it.
* - other_version: the room runs another version of the game. On its Zaisma page the game reloads at the room's version and joins it, and you won't see it; you see it outside Zaisma, through a tester link, or when that version is no longer kept.
* - spectators_full: the room takes no more spectators (its game server's maximumSpectatorCount, 0 when it takes none).
* - already_playing: a player in the room tried to watch it too.
* - spectator_cannot_send: a spectator tried to send to the room ({@link Room.send}, {@link Room.sendBytes}).
* - send_queue_full: the SDK's own: more than 60 reliable sends waited while the room wasn't reachable, so the oldest were dropped. Send less while connectionStatus isn't open, or use latest_only for updates that replace each other.
* - chat_not_allowed, chat_empty, chat_too_long, chat_too_fast: {@link Room.chat} refused (they reject its promise, not the "error" event); chat_not_here: the room's server doesn't take chat.
* - microphone_refused, voice_not_allowed, voice_unavailable: {@link RoomVoice.join} refused (they reject its promise); after joining, the "error" event says when voice stopped. voice_not_here: the room's server doesn't take voice. voice_ticket_required, voice_ticket_refused: on your own server, join needs a ticket your server signed, for this player and game, not expired.
*
* More codes may come within v1: handle one you don't know like an error you can show (its message).
*
* More values may come; treat an unknown one as "request_failed".
*/
type RoomErrorCode =
```
### RequestErrorCode
```ts
| "room_full"
| "room_closed"
| "ended"
| "kept_out"
| "refused"
| "hosting_paused"
| "rented_share_used"
| "account_needed"
| "game_not_open_to_player"
| "game_unavailable"
| "bad_pass"
| "bad_player_token"
| "bad_origin"
| "too_big"
| "too_fast"
| "bad_message"
| "no_hello"
| "not_allowed"
| "busy"
| "room_not_running"
| "blocked_player_here"
| "other_version"
| "spectators_full"
| "already_playing"
| "spectator_cannot_send"
| "send_queue_full"
| "chat_not_here"
| "chat_not_allowed"
| "chat_empty"
| "chat_too_long"
| "chat_too_fast"
| "voice_not_here"
| "microphone_refused"
| "voice_not_allowed"
| "voice_unavailable"
| "voice_ticket_required"
| "voice_ticket_refused";
/**
* The codes a request's errors have ({@link Server.request}), from Zaisma or the Node runner alike:
* - bad_request: not plain JSON with the player's pass.
* - too_big: a request over 16 KB.
* - bad_pass: the player pass wasn't accepted (the SDK gets a new one and tries once more).
* - bad_player_token: off Zaisma, your own server didn't take the playerToken ({@link setUpOffZaisma}); the game gets the player a new one.
* - account_needed: the player is a guest, and the game needs a Zaisma account for multiplayer or the whole game.
* - game_not_open_to_player: the account is younger than the game's minimum age (set on the dashboard); the game never learns its age.
* - game_unavailable: the game can't be played right now.
* - no_request_handler: the game's server has no onRequest.
* - game_server_error: onRequest threw, answered something that isn't plain JSON or over 1 MB, or took over 10 seconds.
* - rented_share_used: this player is on a rented-server network, and the share of the game's hosting such traffic gets is used. Zaisma's page tells them to turn off their VPN or sign in. Everyone else plays on.
* - hosting_paused: the game's hosting on Zaisma is paused this month; requests work again when the month resets (UTC) or its developer adds credit.
* - slow_down: too many requests from this address; try again in a minute.
* - bad_origin: the request didn't come from the game's own page.
* - busy: Zaisma couldn't answer right now; try again soon.
*
* More values may come; treat an unknown one as "request_failed".
*/
type RequestErrorCode =
```
### ErrorCode
```ts
| "bad_request"
| "too_big"
| "bad_pass"
| "bad_player_token"
| "account_needed"
| "game_not_open_to_player"
| "game_unavailable"
| "no_request_handler"
| "game_server_error"
| "hosting_paused"
| "rented_share_used"
| "slow_down"
| "bad_origin"
| "busy";
/**
* The codes the SDK's errors have: a room's ({@link RoomErrorCode}), and:
* - unchecked: no player pass, because the game isn't played on its zaisma.com page or Zaisma couldn't check the browser.
* - no_online_play_in_preview: no player pass, because the game is a preview of a version players don't have yet, so a test build never
* reaches live rooms. Test online play with `npx @zaisma/cli play-locally`, or publish the version and play it through a tester link.
* - unknown_option, unknown_event: a call the SDK doesn't take; the message lists what it does.
* - bad_game_view: {@link Page.setGameView} was given something other than true or false.
* - slow_down: too many calls; try again in a minute.
* - zaisma_rooms_not_used: the game doesn't use Zaisma rooms.
* - bad_report: a report whose reason isn't a {@link ReportReason}, or whose player ID isn't one.
* - report_not_sent: the player closed Zaisma's report sheet, which {@link Room.report} opened, without sending it.
* - feedback_not_sent: the player closed Zaisma's feedback sheet, which {@link Page.openFeedback} opened, without sending it.
* - feedback_not_opened: {@link Page.openFeedback} was called without the player's own press just before it, so nothing opened.
* - bad_game_context: a gameContext that isn't up to 8 short facts ({@link FeedbackContext}).
* - bad_origin: the call didn't come from the game's own page.
* - not_on_zaisma: the game is played off Zaisma, so it has no player passes, sign-in or room lists; joinRoom and server.request need {@link setUpOffZaisma} and a serverUrl.
* - bad_game_slug: {@link setUpOffZaisma}'s gameSlug isn't a game slug: 1 to 40 lowercase letters, digits or hyphens.
* - sign_in_declined: the player chose Not now when the game asked them to sign in ({@link player.signIn}) or showed the "Keep your progress" card ({@link player.offerAccount}).
* - account_offer_too_soon: the "Keep your progress" card already showed this visit, or the player chose Not now in the last 3 days ({@link player.offerAccount}).
* - cloud_saves_off: the game has cloud saves off, so it has no saves on players' accounts ({@link saves}).
* - cloud_saves_not_here: cloud saves don't work where the game is played: a tester link, or a Zaisma without accounts. Save in the browser as usual.
* - bad_save_copy_id: not a save copy ID; they come from {@link Saves.listCopies}, like "save_copy_k2v9q4x7m1p3w8r5t6y0".
* - no_save_copy: the player has no earlier version with that ID in this game.
* - bad_room_code: not a room code, which is six characters like "K7Q2MX", from 2 to 9 and A to Z without I or O.
* - bad_server_url: a serverUrl that isn't a full wss://, ws://, https:// or http:// address ({@link Friends.setRoom} takes only wss:// and https://).
* - unlisted_server: {@link Friends.setRoom} named a server that isn't one of the game's own servers (own_server_urls).
* - connection_closed: the connection to the room closed before it let the player in; the message says why.
* - bad_bytes: {@link Room.sendBytes} was given something other than an ArrayBuffer or a typed array.
* - bad_send_option: a send's delivery or latestKey isn't one it takes; latest_only needs a latestKey.
* - bad_delay: {@link Room.smoothedState}'s delayMs isn't from 0 to 1000.
* - bad_region: a region that isn't a continent code ({@link Region}).
* - bad_idle_timeout: an idleTimeoutSec that isn't from 30 to 86400.
* - bad_transport: a transport that isn't "websocket" or "webtransport".
* - request_failed: Zaisma didn't answer (no connection, or a problem on Zaisma's side); try again.
* - no_game: {@link Items.buy} named a game that isn't open to play here.
* - chat_stopped, chat_not_allowed, chat_empty, chat_too_long, chat_too_fast, chat_not_here: {@link Room.chat} didn't send ({@link ChatErrorCode}).
* - And a request's ({@link RequestErrorCode}).
*
* More values may come; treat an unknown one as "request_failed".
*/
type ErrorCode =
```
### SdkError
```ts
| RoomErrorCode
| RequestErrorCode
| "report_not_sent"
| "feedback_not_sent"
| "feedback_not_opened"
| "bad_game_context"
| "chat_stopped"
| "chat_not_allowed"
| "chat_empty"
| "chat_too_long"
| "chat_too_fast"
| "chat_not_here"
| "unchecked"
| "no_online_play_in_preview"
| "unknown_option"
| "bad_game_view"
| "unknown_event"
| "slow_down"
| "zaisma_rooms_not_used"
| "bad_report"
| "bad_origin"
| "not_on_zaisma"
| "bad_game_slug"
| "sign_in_declined"
| "account_offer_too_soon"
| "cloud_saves_off"
| "cloud_saves_not_here"
| "bad_save_copy_id"
| "no_save_copy"
| "no_player"
| "bad_player_id"
| "bad_room_code"
| "bad_bytes"
| "bad_send_option"
| "bad_delay"
| "bad_region"
| "bad_idle_timeout"
| "bad_transport"
| "bad_server_url"
| "unlisted_server"
| "unknown_link"
| "bad_link_path"
| "bad_item_name"
| "bad_purchase_id"
| "no_purchase"
| "already_handled"
| "handled_by_server"
| "bad_link_query"
| "bad_own_site_url"
| "needs_player_tap"
| "no_game"
| "no_item"
| "not_for_sale"
| "stripe_not_connected"
| "stripe_cannot_take_payments"
| "bad_item_count"
| "bad_game_account_id"
| "connection_closed"
| "request_failed";
/**
* An error from the SDK: its code says what went wrong, for the game to branch on, and its message
* says it in one sentence, with what to fix.
*
* @example
* try { room = await Zaisma.joinRoom(); }
* catch (error) {
* switch (error.code) {
* case "room_full": showRoomFull(); break;
* default: showError(error.message); // codes only grow within v1, so keep a default
* }
* }
*/
interface SdkError extends Error {
code: ErrorCode;
}
```
### InviteStatus
```ts
/**
* What {@link invite} did: "opened" Zaisma's Share on a Zaisma page, or "failed" when the page couldn't
* open it; elsewhere "shared" from the share sheet, "copied" the link, "cancelled" the share sheet, or
* "failed" to do either. More values may come; treat an unknown one as "failed".
*/
type InviteStatus = "opened" | "shared" | "copied" | "cancelled" | "failed";
```
### ChatCheck
```ts
/** What {@link checkChat} found. */
interface ChatCheck {
/** Whether it can be sent. */
isAllowed: boolean;
/** Why not, null when it's allowed ({@link ChatCheckReason}). */
reason: ChatCheckReason | null;
/** The words to show the sender when it's stopped (never about age or the other player); null when it's allowed. */
message: string | null;
/** Whether it swears. Zaisma allows swearing; block it yourself if your game doesn't. */
hasSwearing: boolean;
/** Whether it has a slur. Zaisma allows it too; your game and its moderators decide. */
hasSlur: boolean;
/** The text tidied up: hidden characters and extra spaces gone, line breaks kept (empty when it's too_long). */
text: string;
}
```
### ChatCheckReason
```ts
/**
* Why {@link checkChat} stopped a message: "contact_details" (a link, handle, email, phone number or
* contact app in any disguise, or moving to another app or meeting up), "personal_details" (where
* someone lives, their school, their full name, photos), "sexual" or "too_long" (over 2000 characters).
* "slur" and "unchecked" are v1's and no longer given: slurs are flagged (hasSlur), and what the AI can't
* look at goes after the rules. The game server's ChatCheckReason has two more, "chat_paused" and
* "not_allowed_to_chat", which only a room can give. More values may come; treat an unknown one as a
* stop: show message.
*/
type ChatCheckReason = "contact_details" | "personal_details" | "slur" | "sexual" | "unchecked" | "too_long";
```
### ReportReason
```ts
/** What happened, in a player report. Zaisma looks at real_life_threat (a threat that reaches past the game: their real details, finding them, a plan), personal_details (sharing someone's), following_after_block and sexual (behavior); harassment, cheating and other go to the game's developer. */
type ReportReason = "real_life_threat" | "personal_details" | "following_after_block" | "sexual" | "harassment" | "cheating" | "wrong_age" | "under_13" | "other";
```
### ReportAnswer
```ts
/** Zaisma's answer to a report. */
interface ReportAnswer {
isReported: true;
}
```
### RoomList
```ts
/** The game's listed rooms ({@link Rooms.list}). */
interface RoomList {
/** Rooms with space first (the player's country, then region, then the busiest), then full and closed ones. Up to 50, in the region asked for. */
rooms: ListedRoom[];
/** Everyone playing in the game's rooms everywhere, unlisted rooms too (for "playing now"). */
playingPlayerCount: number;
/** The game's rooms with someone playing, everywhere, unlisted ones too. */
playingRoomCount: number;
/** Listed rooms that are closed to new players, everywhere. */
listedClosedRoomCount: number;
/** Listed rooms a player could join right now, everywhere. */
listedJoinableRoomCount: number;
/** Listed rooms taking players, full ones too, in the region and with the labels asked for: the ones listed plus the ones past them (moreOpenRoomCount). */
matchingOpenRoomCount: number;
/** The regions with listed rooms, busiest first, for a region filter, like { region: "EU", regionName: "Europe", roomCount: 12, playerCount: 48 }. */
regions: { region: Region; regionName: string; roomCount: number; playerCount: number }[];
/** The region the rooms are filtered to, or null for everywhere. */
region: Region | null;
/** Open rooms in that region past the ones listed. */
moreOpenRoomCount: number;
/** Labels worth filtering by: ones several rooms have, with a handful of values. */
filters: { label: string; values: string[] }[];
}
```
### ListedRoom
```ts
/** A room in a room list. Never who's in it. */
interface ListedRoom {
roomCode: string;
/** Players in the match, not counting players who walked away. */
playerCount: number;
/** Seats held for players coming back or on their way: a room has space while playerCount + heldSeatCount < maximumPlayerCount. */
heldSeatCount: number;
maximumPlayerCount: number;
/** Spectators watching the room. */
spectatorCount: number;
/** Spectators the room takes (its game server's maximumSpectatorCount): 0 when nobody can watch. Room to watch while spectatorCount < maximumSpectatorCount, full or closed rooms too. */
maximumSpectatorCount: number;
/** false: closed, so only players who were in it can come back. */
isOpen: boolean;
/**
* Where the room runs: the country its first player connected from, and its region (a continent),
* like { countryCode: "DE", countryName: "Germany", region: "EU" }; null when unknown.
*/
location: { countryCode: string; countryName: string; region: Region | null } | null;
/** In the same region as the player asking. */
isNear: boolean;
/** The room's name, or null. */
name: string | null;
/** The room's labels. */
labels: Record<string, string>;
/** Kept by the game server (room.setKept): a world that stays listed with nobody in it, like a server waiting for players. */
isKept: boolean;
/** The room's link on Zaisma, to join it or pass it on. */
inviteUrl: string;
}
```
More from btc7274
Versions
- 0.92.0Nov 30, 2026 · 12 files · 882 KBNewest
No version has passed its checks yet.





