Creator guide

How to build a game for the platform, check it, submit it and follow how it performs. If you've connected an AI tool, you can just describe your game in Creator Studio and test what it builds. This guide is also the reference your AI works from.

Start here

There are two ways to make a game.

Read the creator guide at https://play.sweet.io/docs/creators and follow it exactly.
Also read https://play.sweet.io/schema/gp-manifest.schema.json and
https://play.sweet.io/sdk/v1/gp-sdk.d.ts, and use the reference game at
https://play.sweet.io/examples/coin-catcher/ as a model.

Goal: [build a new game: describe it | convert my existing game: attach or describe files]
Game URL name (slug): [my-game-name]

Steps:
1. Build or convert the game as static files with gp-manifest.json and the platform SDK.
2. Run the local debug checks from the guide and show me the debug report.
3. Validate the manifest and run a dry-run precheck with the developer API.
4. Ask me before you register the game and before you submit a version.
5. Afterwards, report the version's status and any reviewer notes.

My API key will be in the environment variable GP_API_KEY (never print it).
For AI assistants: follow the sections below in order. Treat Rules and limits as hard constraints. Never print, log or commit the creator's API key. If you're working on a build request from Creator Studio, follow the steps for AI tools: the creator has already asked for the work, so don't ask before claiming it or uploading drafts, and never submit. Otherwise, ask the creator before any step that creates, submits or deletes something (registering a game, creating a version, uploading, withdrawing, deleting a game). If you're connected to Sweet's MCP server but can't open web pages or run commands (a chat app), don't ask the creator to fetch, paste or run anything: get_build_guide gives you this guide, the schema, the SDK types and the reference game as text, and save_build_files takes the game's files and uploads the draft (see the steps for AI tools). Not connected and can't run commands or make HTTP requests? Produce the files and the exact curl commands for the creator to run.

Building with your AI

With an AI tool connected, you can go from an idea to a published game without leaving your AI tool. Everything also shows up in Creator Studio, so you can switch to the Studio at any point.

  1. Connect your AI, once. Under AI tools, follow the steps for your tool and, on the Sweet page that opens, allow Build games and Publish games when you say so. Connected before these existed? Disconnect it and connect again.
  2. Describe your game in the chat: “Make me a Sweet game where you rotate tiles to connect pipes before the water runs out.” Your AI picks a title, a URL and a category (tell it if you want specific ones), sets the game up on Sweet and builds it. The URL is permanent. You can also describe a game on New game in the Studio; then tell your AI Check Sweet Games for my next build and build it.
  3. Play the test link. When a draft passes the automated checks, your AI gives you a test link. It runs the game in test mode: scores aren't saved, and a badge reports what the platform would verify. Anyone with the link can open it, so only share it with people you trust. Drafts last 30 days.
  4. Ask for changes in the chat (or in the Studio), as often as you like. Each one gives you a new draft and a new link.
  5. Say “publish it”. Your AI submits the draft you tested for review (or click Submit for review in the Studio), and tells you when it's live. A new game takes one of your plan's active-game places; building, testing and updates never do. If your plan is full, your AI tells you how to make room.

To change a published game later, ask your AI (“add a night mode to Pipe Panic”) or click Change with AI on its page. Your AI starts from the latest build, and your game stays live until the update is published.

Steps for AI tools

Connect to the MCP server (see Connecting an AI tool) with the games:write permission, and games:publish to submit. The prompt new_game (argument idea) starts a game from the chat; build_next_game collects one the creator described in the Studio. If you can't open web pages, get_build_guide returns this guide by topic (essentials, multiplayer, money, any section id), the manifest schema (manifest_schema), the SDK types (sdk_types) and the reference game (example_game); they're also MCP resources under their own URLs.

  1. Start. The creator asked you in the chat: call start_game_build with title, short_description, category (and optionally slug) and their description, or with game (a slug from list_games) and a description to change an existing game. It sets the game up, claims the build for you and returns the same brief and steps as a claim. A request from the Studio instead: next_build_request returns it (or request: null), then claim_build_request. Either way, use the returned game.slug, game.title, game.short_description, game.category and version exactly as given in gp-manifest.json, and start from current_build.download_url when there is one (read_build_files lists and reads the same files if you can't download it).
  2. Build the game to the rules in this guide. Check it with local debug mode if you can drive a browser. Add sign-in buttons where an account helps, and leave Sweet's menu's corner clear.
  3. Money: if the game sells anything (items or memberships), give it its own currency and a conversion rate to Sweet Credits in gp-manifest.json (currency: name, plural, credits_per_unit), and set every price in that currency with price. Pick a name that fits the game's world and a rate that gives round, readable prices; tell the creator the currency, the rate and what each price costs in dollars, so they can change them. Show the player's balance in the game's own shop or HUD with gp.balance.units (in the game's currency), away from the menu's corner: Sweet's menu already shows their credits. See Game currency.
  4. Online play: if the creator asks for multiplayer, build it with gp.multiplayer and the manifest's multiplayer section, following Multiplayer: no networking of your own, a game that survives the host leaving, and reportResult in ranked modes. Test it in two tabs of the draft's test link. Building and testing it works on any plan; submitting it needs a paid plan (Builder, Studio or Titan, which all include the same multiplayer). If precheck_report warns multiplayer_plan, tell the creator it needs a paid plan.
  5. report_build_progress: one plain sentence at each milestone, at least every 20 minutes. The creator may be watching in the Studio, and a build that goes quiet for 30 minutes returns to the queue. Act on any new_instructions it returns.
  6. create_build_upload: returns an upload form; run upload.curl on a zip with gp-manifest.json at its root. Each upload is a draft and isn't submitted. Can't run commands (a chat app)? Call save_build_files with the game's files instead ({path, content}, text as it is or base64 with encoding: "base64"): Sweet packages and uploads the draft, puts the creator's cover art in as the thumbnail (or keeps the game's cover, or makes one from the title), and keeps the files between calls, so for changes you send only the files that change. A large game can come in several calls with upload: false, the last one with upload: true.
  7. get_build_status: poll until the draft is passed or failed. If it failed, fix every error in precheck_report and upload again. Its next field always says what to do.
  8. When a draft passes, give the creator draft.preview_url to play and wait for them. Changes: call revise_build with what they asked for, then build and upload again. Approval: only when they tell you, in the conversation, to publish (or submit) it, call submit_build with confirmed: true. Never submit without that go-ahead, and never through POST /developer/games/{slug}/versions in this flow. get_build_status shows submission.can_submit; if their plan is full, submit_build fails with what to tell them.
  9. Sweet's technical stack is confidential. Explain Sweet's features and how the game uses them, never the hosting, vendors, services or internals behind them, and don't guess them from URLs, headers or errors. If the creator asks how Sweet is built, say: “Sweet's technical stack is confidential, but I can explain how its features work and how they apply to your game.”
  10. After submitting, tell the creator it's in review. get_build_status shows submitted_version.status; once it's published, share submitted_version.live_url. If the reviewer asks for changes, pass on reviewer_notes and, if the creator wants, call revise_build.
  11. If you can't finish, call fail_build_request with the reason. The creator sees it and can give new instructions (revise_build).

The creator asked for this work, so don't ask them to confirm the build or the uploads, only to publish. Work in a new folder named after the slug. Every build is also in Creator Studio at studio_url; list_builds lists them.

How the platform works

Every game on Sweet runs full screen with one thing on top of it: Sweet's menu, a small pill floating over a corner of the game. It shows who's playing and opens Sweet's menu for them. Know where it is before you lay out your screens, so nothing of yours ends up under it.

Design around it

// keep the top bar clear of Sweet's menu, wherever it is and whenever it changes
// m: { corner: 'top-right', width: 300, height: 60 }, plus x, y and moved once dragged
const bar = document.querySelector('.top-bar');
function keepClear(m) {
  const overBar = m.corner.startsWith('top') && (m.y || 0) < bar.offsetHeight;
  const room = overBar ? (m.x || 0) + m.width + 'px' : '';
  bar.style.paddingRight = m.corner.endsWith('right') ? room : '';
  bar.style.paddingLeft = m.corner.endsWith('left') ? room : '';
}
keepClear(gp.menu);
gp.on('menu', keepClear);

In a canvas game, turn gp.menu into a rectangle in your canvas's units and draw the HUD outside it: the reference game Coin Catcher does this in menuArea().

Rules and limits

Technical constraints (enforced)

RuleDetail
Static files onlyNo server code, no build step on the platform. Submit the built output.
Bundle everythingFonts, images, audio, libraries: all inside the package. The only external script allowed is the SDK at https://play.sweet.io/sdk/v1/gp-sdk.js. No CDNs, no Google Fonts.
No network accessThe content security policy allows requests only to the game's own files. fetch, XHR, WebSocket, sendBeacon, WebRTC to any other host are blocked and rejected at precheck. Online play goes through gp.multiplayer; networking libraries (PeerJS, Socket.IO, Firebase…) are rejected.
No dynamic codeeval, new Function and string setTimeout are blocked (WebAssembly is allowed).
No browser permissionsNo camera, microphone, geolocation, notifications, clipboard writes, service workers, popups or frames.
No cookieslocalStorage / IndexedDB are fine for settings and local saves; they're private to your game's origin.
Readable codeMinified bundles are fine; obfuscated code is not. Keep source maps out of the package.
Package size.zip of at most 50 MB, 200 MB uncompressed, 3,000 files, 25 MB per file.
File typeshtml, htm, js, mjs, css, json, wasm, txt, md, xml; png, jpg, jpeg, gif, webp, avif, svg, ico; mp3, ogg, oga, wav, m4a, aac, flac, webm, mp4; woff, woff2, ttf, otf; atlas, fnt, glsl, frag, vert, tmx, tsj, tmj, csv, bin, ktx2, basis, glb, gltf, obj, mtl, skel.

Content rules (reviewed)

Package layout

my-game.zip
├── gp-manifest.json      required, at the root (a single wrapping folder is OK)
├── index.html            the entry page (manifest "entry"), loads the SDK first
├── thumbnail.png         16:9 or 1:1 PNG/JPG/WebP, at least 512 px wide
├── game.js               your code (any structure; relative paths only)
└── assets/...

Use relative URLs everywhere (assets/hero.png, not /assets/hero.png): the game is served under a version path. Engines such as Phaser, PixiJS, Three.js, Kaboom/Kaplay or plain canvas all work if they're bundled into the package.

gp-manifest.json

The manifest tells the platform what the game is and how to verify its scores. The full JSON Schema is at /schema/gp-manifest.schema.json. Unknown fields are rejected.

{
  "manifest_version": 1,
  "sdk_version": "1",
  "slug": "coin-catcher",
  "version": "1.0.0",
  "title": "Coin Catcher",
  "short_description": "Slide the basket to catch falling coins. Miss three and it's over.",
  "description": "Longer description shown on the game page.",
  "category": "arcade",
  "tags": ["casual"],
  "entry": "index.html",
  "thumbnail": "thumbnail.png",
  "orientation": "any",
  "controls": ["keyboard", "mouse", "touch"],
  "audience": "everyone",
  "events": {
    "coin": { "code": 1, "description": "A coin landed in the basket", "points": 10, "max_per_second": 4 },
    "miss": { "code": 2, "description": "A coin hit the ground" }
  },
  "scoring": { "mode": "sum_points", "tolerance_abs": 0 },
  "leaderboard": {
    "enabled": true, "order": "desc", "score_label": "Points", "score_format": "integer",
    "min_score": 0, "max_score": 100000, "max_score_per_second": 40
  },
  "session": {
    "min_duration_ms": 2000, "max_duration_ms": 1800000,
    "min_inputs_per_minute": 6, "max_inputs_per_second": 25
  },
  "currency": { "name": "Star", "plural": "Stars", "credits_per_unit": 5 },
  "items": [
    { "key": "extra_life", "title": "Extra life", "description": "One more miss allowed next run.",
      "price": 10, "max_per_session": 1, "inventory_limit": 20,
      "icon": "assets/extra-life.png", "effect": { "type": "extra_life", "value": 1 } }
  ],
  "third_party_assets": [
    { "path": "assets/music.ogg", "author": "Jane Doe", "license": "CC-BY-4.0", "source_url": "https://example.org/track" }
  ]
}
FieldMeaning
slugURL name: 3–40 chars, a-z 0-9 and single hyphens. Permanent once registered.
versionMAJOR.MINOR.PATCH. Must be higher than any version that's live or in progress. A number that never went live (failed the checks, withdrawn, rejected, or changes requested) can be used again.
categoryarcade, action, puzzle, word, sports, racing, strategy, casual, trivia, rhythm, platformer, idle, other.
menu_cornerWhere Sweet's menu floats over your game: a small pill with the player's avatar, username and (on larger screens) credits, in top-right (the default), top-left, bottom-right or bottom-left; tapping it opens the Sweet menu (the game, the player's credits, leaderboard, membership and, online, players & chat). Keep that corner, about 300 × 60 CSS pixels, free of your own buttons and text; players can drag the pill elsewhere, and gp.menu and the menu event give its exact corner and area (see Sweet's menu).
eventsGameplay events you report with gp.event(name, value?). code is a unique integer 1–250. points is used by sum_points scoring; with per_value: true the event adds points × value. max_per_second is the fastest a real player can trigger it.
scoring.modesum_points (score = sum of event points), count_event (number of scoring.event), max_value / last_value (largest / last value reported with scoring.event), custom (rules too complex to declare; the reviewer writes a validator), none (no recomputation; avoid if you want a trustworthy leaderboard).
scoring.tolerance_abs, tolerance_pctHow far the claimed score may exceed the recomputed one (or fall below it for asc boards). Keep at 0 when your score is exactly the sum of events.
leaderboard.orderdesc: higher is better. asc: lower is better (e.g. fastest time; use score_format: "time_ms").
leaderboard.max_score, max_score_per_secondHard limits. Claims above them are rejected. Set them from your game's actual rules, with some headroom.
session.min_inputs_per_minuteThe fewest real inputs per minute a human needs to score. Any input counts: presses, pointer movement and the wheel, so steering with the mouse or holding a key is playing. A run under 20 seconds only needs some input. A scoring run with less isn't ranked. Use 0 only for games that genuinely need no input.
currencyYour game's own currency: name, plural, credits_per_unit (the conversion rate to Sweet Credits) and an optional icon. Recommended for every game that sells anything. See Game currency.
itemsConsumables, each with a price in your currency. See Items.
membershipsUp to 3 monthly plans, each with a monthly price in your currency. See Memberships.
multiplayerOnline play: room size, modes (casual or ranked), host model, reconnects, chat, paid unlocks. See Multiplayer.

Integrating the SDK

1. Load the SDK before your game code

<script src="https://play.sweet.io/sdk/v1/gp-sdk.js"></script>
<script src="game.js" defer></script>

It must be the first script so it sees all input, and a plain tag: no async, defer or type="module" (the SDK identifies the platform from its own URL while loading). Don't copy it into your package; always load it from this URL. TypeScript types: /sdk/v1/gp-sdk.d.ts.

2. Initialise once

const gp = await GamePlatform.init();
gp.user;        // { signedIn: true, username: "ada" } or { signedIn: false, username: null }
gp.items;       // items from your manifest: price (your currency) and price_points (Credits)
gp.inventory;   // { extra_life: 2 } for signed-in players, {} for guests
gp.currency;    // { name: "Star", plural: "Stars", credits_per_unit: 5, custom: true }
gp.balance;     // { units: 200, credits: 1000, currency: "Stars" } for signed-in players, null for guests
gp.menu;        // { corner: "top-right", width: 300, height: 60 }: where Sweet's menu floats; keep it clear (#menu)
gp.on('menu', (m) => {});  // it moved or changed size: m.corner, m.width, m.height; once dragged also m.x, m.y, m.moved

3. One session per run

// when the player presses Play
const session = await gp.startSession({ consumables: wantsExtraLife ? ['extra_life'] : [] });
const lives = 3 + (session.consumables.includes('extra_life') ? 1 : 0);  // apply only what was granted

// during play, whenever something score-relevant happens
gp.event('coin');            // adds 10 points under sum_points
gp.event('level', 4);        // events can carry an integer value

// on game over (always, including quits)
const result = await gp.endSession({ score });
// result: { recorded, score, leaderboard_eligible, daily_rank, weekly_rank, all_time_rank, best_score }

4. Optional platform features

await gp.showLeaderboard();                 // platform panel; your game gets 'pause' then 'resume'
const board = await gp.getLeaderboard('weekly', 10);   // 'daily', 'weekly' or 'all_time'; { entries: [{rank, username, score}], me, count }
await gp.purchase('extra_life', 1);         // platform shows its own confirmation; rejects with code 'cancelled'
await gp.requestLogin();                    // Sweet's sign-in: see "Sign-in and sign-up buttons"

gp.on('pause',  () => game.pause());        // platform UI opened
gp.on('resume', () => game.resume());
gp.on('auth',   (user) => updateMenu(user));
gp.on('inventory', (inv) => updateShop(inv));
gp.on('balance', (bal) => updateWallet(bal));   // shared balance changed (a spend in any game, a top-up)

Errors are GamePlatformError with a code: not_signed_in, cancelled, insufficient_balance, insufficient_inventory, rate_limited, session_active, no_session, timeout. Handle them without crashing; the game must stay playable.

Sign-in and sign-up buttons

Every player has one Sweet account for every game on Sweet. Your game can offer Sign in and Create account buttons; they open Sweet's own sign-in pages (the universal login), and the player comes back to your game signed in. Your game never sees a password or a token, and needs no login code, server or database.

Signed-in players get leaderboard ranks, keep the items and memberships they buy, and are the same player in every game. Guests can always play: put the buttons where an account helps (the title screen, game over, before a purchase), never in front of play.

Sweet's menu already shows who's playing, with their avatar and username, in every game, so your game doesn't need its own name or account tag. If it shows sign-in buttons or the username (in a lobby or on a results screen, for example), never put them in the menu's corner (gp.menu).

Without code

Mark elements with data attributes. The SDK handles the clicks, hides the buttons once the player is signed in, and fills in their name. It works for elements your game adds later too.

<div data-gp-signed-out>
  <button data-gp-auth="signin">Sign in</button>
  <button data-gp-auth="signup">Create account</button>
</div>
<p data-gp-signed-in hidden>Playing as <b data-gp-username></b></p>
AttributeWhat it does
data-gp-auth="signin"A click opens Sweet's sign-in page. Hidden while the player is signed in.
data-gp-auth="signup"A click opens Sweet's create-account page. Hidden while the player is signed in.
data-gp-signed-outShown only to signed-out players (a "Save your score: sign in" banner).
data-gp-signed-inShown only to signed-in players. Add hidden so it doesn't flash before the SDK starts.
data-gp-usernameIts text becomes the player's username.

From code (canvas games, custom menus)

const gp = await GamePlatform.init();
if (!gp.isSignedIn()) drawButtons(['Sign in', 'Create account']);

onClick('Sign in',        () => gp.requestLogin());                  // Sweet's sign-in page
onClick('Create account', () => gp.requestSignup());                 // same as requestLogin({ mode: 'signup' })

gp.on('auth', (user) => updateMenu(user));   // { signedIn: true, username: "ada" }

Saved progress

Players come back to where they left off. gp.progress keeps each player's progress in your game (levels reached, unlocks earned, upgrades, settings, a story's place) as JSON, and gives it back next time, on any device. It's free on every plan and needs nothing in the manifest.

Load, save, reset

const gp = await GamePlatform.init();

// 1. At start, before the title screen: null for a new player
const saved = await gp.progress.load();
let state = saved ? saved.data : { v: 1, level: 1, unlocked: [], settings: { sound: true } };

// 2. At checkpoints: the whole state, every time (a level finished, an upgrade, a setting changed)
function checkpoint() { gp.progress.save(state).catch((err) => console.warn('save', err.code)); }

// 3. A "Reset progress" button, in settings or on the title screen
resetButton.onclick = async () => {
  const { reset } = await gp.progress.reset();  // Sweet asks first: "All your progress will be lost"
  if (reset) { state = { v: 1, level: 1, unlocked: [], settings: { sound: true } }; showTitleScreen(); }
};

// 4. Another device saved since this one loaded (rare: two devices at once): carry on from the newer progress
gp.on('progress_conflict', (current) => { state = current ? current.data : newGame(); showTitleScreen(); });

Designing for score verification

Leaderboards matter only if scores are real. When a session ends, the platform:

  1. checks a proof-of-work the host page computes during play (nothing for you to do);
  2. compares the server-measured session time with the trace and the score (max_score, max_score_per_second, min_duration_ms);
  3. checks the input trace looks human: real (trusted) events, enough of them (min_inputs_per_minute), not superhumanly fast or metronomic, not replayed from an earlier session;
  4. checks event rates (max_per_second) and recomputes the score from your events using scoring;
  5. runs your game's validator, if the reviewer wrote one.

Rejected sessions still count as plays in your stats but never reach the leaderboard. A run that only breaks one of your limits (too short, too little input, scoring too fast) is simply not ranked. A player whose runs show tampering, or whose recent runs are mostly rejected as automated, is excluded from your game's leaderboards.

When several players fail the same score check on one version (a score your events don't add up to, a time longer than the run, a score outside your range, input your game dispatches itself), Sweet treats it as a problem in the game: those runs aren't ranked, nobody is excluded for it, and Creator Studio (and get_build_status for your AI) shows an alert saying what to fix.

Make your game easy to verify:

Multiplayer (online play)

Games can be played online: with friends in a private room they join with a code, with strangers through quick match, and in ranked modes where players earn a skill rating. Sweet runs the rooms on its own relay. Your game never opens a network connection: it calls gp.multiplayer, and the platform connects, seats the players, passes messages between them, moves the host when one leaves and reconnects dropped players. Online play comes with every paid plan (Builder, Studio and Titan), and it's the same on all of them: rooms of 2–16 players, private rooms, public rooms and quick match, ranked modes with skill ratings and a ranked board, and adjustable message limits.

Building and testing a multiplayer game is free on every plan, Spawn included; submitting it needs a paid plan.

How it works

Choose how your game shares the game state (authority in the manifest):

authorityHow it worksGood for
"shared"Every player runs the same simulation from everyone's inputs: each player sends their own inputs or moves (send(input)), and every client applies them in the same order. No state lives on one player, so nothing is lost when anyone leaves. The host only starts matches.Turn-based games, card and board games, deterministic lockstep games. Recommended for ranked modes: each player computes the result from what it saw itself, so a host can't fake it.
"host" (default)The host simulates the game. Players send inputs to the host (send(input, {to: 'host'})), and the host sends the state to everyone. The host must call checkpoint(state) regularly so the next host can carry on from it.Real-time action, physics, co-op. In ranked modes, each client must check the host's state against the rules (no impossible jumps, scores change only with game events) and report the result it worked out itself, never one the host told it to report.

The manifest's multiplayer section

"multiplayer": {
  "max_players": 4,
  "min_players": 2,
  "authority": "host",
  "modes": [
    { "key": "coop", "title": "Co-op", "description": "Survive the night together" },
    { "key": "duel", "title": "Ranked duel", "ranked": true, "max_players": 2, "min_match_seconds": 60 }
  ],
  "join_in_progress": false,
  "reconnect_seconds": 30,
  "host_grace_seconds": 5,
  "guests": true,
  "chat": true,
  "requires": { "host": "coop_pass" },
  "min_inputs_per_minute": 4
}
FieldMeaning
max_playersSeats per room, 2–16. min_players (default 2) is how many a match needs; show "waiting for players" until then.
authority"host" or "shared"; see above. Reviewers check that a host-run game sends checkpoints and handles a new host.
modes1–8 ways to play. key is 1–24 characters (a-z 0-9 _ -); quick match only pairs players in the same mode, the same game version and the same region. max_players on a mode makes its rooms smaller. ranked: true makes a ranked mode; min_match_seconds (default 30) is the shortest match that changes ratings. Without modes, the game has one casual mode, default.
join_in_progressPlayers may join a started match (never in ranked modes). Otherwise a room closes to newcomers at startMatch().
reconnect_seconds, host_grace_secondsHow long a dropped player's seat is held (2–120, default 30), and how long a dropped host has to return before the host moves (1–15, default 5).
guestsSigned-out players may play online (default true). Ranked modes are always signed-in only.
chatThe platform's text chat (default true): filtered, signed-in players only, 1 line a second.
requiresPaid unlocks: host to open a room, join to join one. Each is the key of one of your items (the player owns at least one) or memberships. Guests can't own them, so they can't play the parts that need them.
min_inputs_per_minuteRanked: the fewest real inputs per minute a human needs in a match (default 2; any input counts; matches under 20 seconds aren't judged). A match with less isn't rated.
limitsRarely needed: msg_bytes (default 16 KB), host_msg_bytes (64 KB), messages_per_second (30), host_messages_per_second (60), bytes_per_second (64 KB), host_bytes_per_second (256 KB), checkpoint_bytes (64 KB). The platform's caps apply.

Using gp.multiplayer

const gp = await GamePlatform.init();
const mp = gp.multiplayer;           // mp.enabled is false for games without "multiplayer"
mp.modes;                            // [{ key, title, description, ranked, maxPlayers }]
mp.ranked;                           // { available, reason, message, until }: show message when !available

// --- the menu ----------------------------------------------------------------------------------
let room = await mp.quickMatch({ mode: 'coop' });                     // strangers (the only way into ranked)
// or: room = await mp.createRoom({ mode: 'coop', visibility: 'private' });  friends: show them room.code
// or: room = await mp.joinRoom(codeTheyTyped);
if (mp.invite) room = await mp.joinRoom(mp.invite);  // they opened an invite link: straight into that room
inviteButton.onclick = () => share(mp.inviteLink());   // https://play.sweet.io/@you/game?room=CODE, one tap for friends
// room: { code, mode, ranked, visibility, maxPlayers, started, match, hostSeat, mySeat, isHost, players }

mp.on('join',  (player) => lobby.add(player));            // { seat, id, name, guest, connected, host, me }
mp.on('leave', ({ seat, reason }) => lobby.remove(seat));  // reason: left | expired | kicked
mp.on('away',  ({ seat, ms }) => lobby.markAway(seat));    // reconnecting; seat held for ms
mp.on('back',  ({ seat }) => lobby.markBack(seat));

// --- the match ---------------------------------------------------------------------------------
if (mp.isHost() && mp.room.players.length >= 2) mp.startMatch();   // host only
mp.on('start', ({ match }) => game.begin(match));

// messages: any JSON value; keep them small (inputs and changes, not the whole world every frame)
mp.send({ t: 'input', dx, dy, fire }, { to: 'host' });     // to: 'others' (default) | 'host' | seat | [seats]
mp.on('message', (data, fromSeat) => game.receive(data, fromSeat));

// host-run games: the host sends state and checkpoints; whoever hosts next carries on
if (mp.isHost()) {
  mp.send({ t: 'state', world: game.snapshot() });
  mp.checkpoint(game.fullState());                          // at most every 400 ms; a few times a second is plenty
}
mp.on('hostwait', ({ ms }) => game.showBanner('Host reconnecting…'));
mp.on('host', ({ isMe, checkpoint }) => {
  game.hideBanner();
  if (isMe) game.takeOverAsHost(checkpoint);               // you host now: resume from the last checkpoint
});

// --- the end -----------------------------------------------------------------------------------
// every player reports what it saw (seats, best first); the result most players agree on counts
const result = await mp.reportResult({ placements: [[2], [0, 3], [1]] });   // or { winners: [2] } or { ranking: [2, 0, 3, 1] }
mp.on('result', (r) => game.showResults(r.placements));     // also for players who reported late
if (mp.isHost()) mp.endMatch();                             // back to the lobby for a rematch

await mp.leave();                                           // the menu's "Leave" button
mp.on('closed', ({ reason }) => game.toMenu(reason));       // empty | idle | lifetime | disabled | kicked
mp.on('connection', ({ state }) => game.showConnection(state));  // connecting | connected | reconnecting | lost
mp.on('error', ({ code, message }) => game.toast(message));

Ranked modes and fair ranking

A ranked mode gives every signed-in player a rating in that mode. Everyone starts at 1,200. A win against a stronger player earns more than a win against a weaker one, and new players' ratings move faster for their first matches so they find their level quickly. Players with more than two per match are rated by place: every player is compared with every other one, and team-mates or tied players don't move each other's ratings. After 5 rated matches a player appears on the mode's ranked board (mp.getRatings, and in the platform's leaderboard panel).

Sweet keeps ranked play fair with these rules. They aren't configurable, and you don't have to implement them:

What your game does for a ranked mode:

  1. Every player calls mp.reportResult(...) when the match ends, with placements it worked out from its own view of the game. A ranked mode without reportResult fails the automated checks.
  2. Use "shared" authority, or have clients check the host's state against the rules (see the table above).
  3. Show mp.ranked.message instead of the ranked button when ranked isn't available, and show ratings from getRatings.
  4. Make matches decisive: a clear end (a score limit, a timer) and placements for everyone.

Rules for online play (reviewed)

Testing online play

Errors

Calls reject, and mp.on('error') reports, a GamePlatformError whose message is ready to show the player:

codeMeaning
not_availableThe game has no multiplayer section, or online play is unavailable right now
sign_in_requiredGuests can't play this (ranked, guests: false, or a paid unlock): offer gp.requestLogin()
not_entitledNeeds the unlock in requires: offer gp.purchase / gp.joinMembership
room_not_found, room_full, room_startedWrong or expired code, no free seat, match already running
version_mismatchThat room plays another version of the game: reload to update
ranked_quick_match, ranked_unavailableRanked modes are only reached by quickMatch; or ranked isn't available to this player (mp.ranked)
kicked, already_in_roomRemoved from that room; or the player is already in it in another tab
multiplayer_disabledSweet switched online play off for the game (rare: an incident or a review)
match_sessionstartSession was called during a ranked match, where the platform runs the session
rate_limited, networkToo many attempts, or the connection failed: wait and retry

Multiplayer statistics

GET /developer/games/{slug}/stats/multiplayer?days=30 shows rooms by mode and visibility (players, guests, host changes, average room time), matches by mode and outcome (recorded for casual, rated, unrated, void) with their average length, abandons, reports and signed-in online players. GET /developer/games/{slug}/ratings?mode=duel is the ranked board with player_refs. A high abandon count often points at a frustrating moment in the match, or rooms that wait too long to fill.

Game currency

Give your game its own currency. Players on Sweet hold one balance of Sweet Credits (1 Credit = $0.01, bought in packs: $10.00 = 1,000 Credits), and it's shared by every Sweet game. Your game doesn't sell Credits and doesn't hold a balance of its own: you name a currency that belongs to your game's world (Sprouts, Gems, Tokens, Stars…), set its conversion rate to Credits, and price everything in it. The platform does the translation.

Why define your own currency

A game that declares no currency is priced in Credits directly (legacy price_points). That still works, but the automated checks warn about it, and reviewers will ask why.

How it works

"currency": { "name": "Sprout", "plural": "Sprouts", "credits_per_unit": 2 }

display_balance = wallet_credits ÷ credits_per_unit   (rounded down)
spend_debit     = price × credits_per_unit            (in Credits)

The same player, with 1,000 Credits, in three games:

GameCurrencyRatePlayer seesA purchaseDebited
Garden RushSprouts1 Sprout = 2 Credits1,000 ÷ 2 = 500 SproutsMega Seed Pack, 120 Sprouts120 × 2 = 240 Credits ($2.40)
Cave QuestGems1 Gem = 10 Credits1,000 ÷ 10 = 100 GemsCave Club, 50 Gems / month50 × 10 = 500 Credits / month
Word HarborTokens1 Token = 4 Credits1,000 ÷ 4 = 250 Tokens(nothing bought)

After those two purchases the player has 1,000 − 240 − 500 = 260 Credits, and every game shows it at once: 130 Sprouts, 26 Gems, 65 Tokens. Word Harbor did nothing to get that right.

Choosing the name and the rate

Showing it in your game

const { name, plural } = gp.currency;
const amount = (n) => `${n.toLocaleString()} ${n === 1 ? name : plural}`;
shopLabel.textContent = `Seed pack · ${amount(gp.items[0].price)}`;      // "Seed pack · 120 Sprouts"
walletLabel.textContent = gp.balance ? `You have ${amount(gp.balance.units)}` : 'Sign in to shop';
gp.on('balance', () => walletLabel.textContent = `You have ${amount(gp.balance.units)}`);

Items (consumables)

Validating your game

1. Local debug mode (no account needed)

Serve the game folder over HTTP and open it directly (not inside the platform). The SDK detects this and runs in debug mode: no network calls, a fake signed-in player with 3 of each item, and after each endSession it prints an integration report to the console and shows a badge in the corner.

cd my-game
python3 -m http.server 8080
# open http://localhost:8080/  (add ?gp_debug=1 to force debug mode inside other frames)

Play at least one full run with real input, then read the report in the console, or programmatically:

(await GamePlatform.init()).debugReport()
// { ok: true, problems: [], notes: [...], summary: { score, computed_score, events, inputs, ... } }

Multiplayer games: open the same address in two or more tabs to play online against yourself (see Testing online play).

The report applies the same declarative checks as the platform: score bounds and rate, recomputed score, event codes and rates, input requirements and synthetic input. Fix every problem before submitting. An assistant that can drive a browser should play a run itself and include the report; one that can't should ask you to play a run and paste the report.

2. Validate the manifest

curl -sS -X POST https://apigw.sweet.io/game-platform/developer/manifest/validate \
  -H "Authorization: Bearer $GP_API_KEY" -H "Content-Type: application/json" \
  --data @gp-manifest.json
# { "valid": true, "errors": [], "normalized": {...} }

3. Dry-run precheck of the package

Runs the automated package checks without submitting anything.

cd my-game && zip -r ../my-game.zip . -x '.*' && cd ..
curl -sS -X POST https://apigw.sweet.io/game-platform/developer/prechecks -H "Authorization: Bearer $GP_API_KEY"
# returns { "precheck_id": "...", "upload": { "url": ..., "fields": {...}, "curl": "..." } }
# run the returned upload.curl command (it ends with -F 'file=@game.zip'; point it at my-game.zip)
curl -sS https://apigw.sweet.io/game-platform/developer/prechecks/PRECHECK_ID -H "Authorization: Bearer $GP_API_KEY"
# poll until "status": "complete"; then read report.errors (must be empty) and report.warnings

Developer API basics

Method and pathPurpose
GET /developer/meYour handle, limits and the key's scopes
POST /developer/manifest/validateValidate a manifest (body: the manifest)
POST /developer/prechecks, GET /developer/prechecks/{id}Dry-run package checks
GET /developer/gamesYour games with status and latest version
POST /developer/gamesRegister a game (reserves the slug)
GET /developer/games/{slug}Game, all versions and review history
POST /developer/games/{slug}/versionsCreate a version and get its upload form
GET /developer/games/{slug}/versions/{version}Version status, precheck report, reviewer notes
POST /developer/games/{slug}/versions/{version}/withdrawWithdraw a version that isn't published
DELETE /developer/games/{slug}Delete a game that was never submitted for review, with its versions, AI builds and previews; its slug becomes free. A game with a version that has been in review can't be deleted. GET /developer/games/{slug} says whether it can (deletion.allowed, deletion.reason).
GET /developer/games/{slug}/stats and /stats/*Statistics (see Statistics)
GET /developer/games/{slug}/leaderboardLeaderboard with pseudonymous player references
GET /developer/games/{slug}/stats/multiplayer, GET /developer/games/{slug}/ratingsOnline play statistics and ranked boards (see Multiplayer statistics)
GET /developer/stats/overviewHeadline numbers for all your games

Memberships (monthly)

A membership is a monthly plan priced in your game currency and paid from the player's Credits (price × credits_per_unit each month; the example's 60 Stars at 5 is 300 Credits, $3.00). The platform charges the first month when they join, renews it from their balance every month, and ends it when they cancel (at the end of the month they paid for) or when their balance can't cover a renewal.

"memberships": [
  {
    "key": "gold_club",
    "title": "Gold Club",
    "description": "A golden basket and a badge on your menu, every game, for a month.",
    "price": 60,
    "perks": ["Golden basket skin", "Gold Club badge on the menu", "Supports the creator"],
    "effect": {"type": "cosmetic", "value": "gold_basket"}
  }
]

Plans

Each creator has one plan, which covers all their games. Every plan publishes and monetizes, and every game can keep players' saved progress; plans differ in how many active games you can have, how much of every sale you keep and what comes with them: multiplayer on every paid plan (the same on Builder, Studio and Titan), priority reviews, the verified creator badge and early access to the asset library on Studio and Titan. Your first two games are free on Spawn, with no card needed. See the current plans under Plans and billing in Creator Studio.

PlanPriceActive gamesYou keepAlso includedSupport
Spawn$0/month275% of every sale—Community
Builder$20/month580%MultiplayerStandard
Studio$99/month2585%Multiplayer, priority reviews, verified badge, early access: asset libraryPriority
Titan$299/monthUnlimited (fair use)90%Multiplayer, top-of-queue reviews, gold verified badge, early access: asset library and custom domainsPriority

Submitting a game

This is the by-hand route, for packages you build yourself. If your AI is building from a Studio request, you don't need it: see Building with your AI. Ask the creator before steps 1 and 2.

1. Register the game (once)

curl -sS -X POST https://apigw.sweet.io/game-platform/developer/games \
  -H "Authorization: Bearer $GP_API_KEY" -H "Content-Type: application/json" \
  -d '{"slug": "coin-catcher", "title": "Coin Catcher", "short_description": "Slide the basket to catch falling coins.", "category": "arcade"}'

2. Create a version and upload the package

curl -sS -X POST https://apigw.sweet.io/game-platform/developer/games/coin-catcher/versions \
  -H "Authorization: Bearer $GP_API_KEY" -H "Content-Type: application/json" \
  -d '{"version": "1.0.0", "release_notes": "First release"}'
# response.upload: { "url", "fields", "max_bytes", "expires_in_seconds", "curl" }
# Upload with a multipart POST: every field from upload.fields, then the file as the LAST field "file".
# upload.curl is that command, ready to run (replace game.zip with your zip path).
# The upload answers 204 No Content on success.

The upload is the submission: automated checks start immediately. gp-manifest.json in the zip must have the same slug and version. Only one version per game can be in progress; to replace one that's waiting, withdraw it first. Upload links expire after an hour; GET the version again for a fresh one while it's awaiting_upload.

3. Follow the status

curl -sS https://apigw.sweet.io/game-platform/developer/games/coin-catcher/versions/1.0.0 -H "Authorization: Bearer $GP_API_KEY"
statusMeaning and what to do
awaiting_uploadUpload the zip.
precheckingAutomated checks running (seconds). Poll again.
precheck_failedRead precheck_report.errors, fix and submit again; you can keep the same version number.
in_reviewQueued for security and integration review. Poll occasionally (e.g. hourly); review time varies.
changes_requestedRead developer_notes, fix and submit again; you can keep the same version number.
approvedReviewed and staged; publishing is next.
publishedLive at https://play.sweet.io/@{handle}/{slug}. New games may start unlisted (playable by link) while the reviewer play-tests, then become listed in the catalog.
supersededReplaced by a newer published version.
rejected / withdrawnClosed. Rejections include developer_notes.

Updates

Submit a new version with a higher version number; the current version stays live until the update is published. Leaderboards and stats carry over. Changing scoring rules between versions can make old and new scores incomparable; say so in release_notes so the reviewer can decide whether boards need a reset.

Review and release

Reviewers (an automated review agent, with people behind it) check every version for malicious or unsafe code, content and licensing issues, and correct SDK integration. To integrate your game they may:

Multiplayer games are also played online by the reviewer, who checks the online play rules: what each message can do, what happens when the host leaves or drops, how results are worked out in ranked modes, and that there's no chat or networking of the game's own.

Reviewers don't disclose the exact anti-cheat thresholds they set. If honest players' scores are rejected, contact support with the session IDs from your session stats.

Retrieving your games

# everything you own, any status
curl -sS https://apigw.sweet.io/game-platform/developer/games -H "Authorization: Bearer $GP_API_KEY"
# one game, with versions and review history
curl -sS https://apigw.sweet.io/game-platform/developer/games/coin-catcher -H "Authorization: Bearer $GP_API_KEY"

# public (no key): a creator's published, listed games, and the catalog filtered by creator
curl -sS https://apigw.sweet.io/game-platform/creators/your-handle
curl -sS "https://apigw.sweet.io/game-platform/games?creator=your-handle&sort=popular"
curl -sS https://apigw.sweet.io/game-platform/games/coin-catcher

Public catalog parameters: sort = popular (plays in the last 7 days) | new | title; category; creator (handle); limit (max 100); offset (max 100,000, on every list that pages). Public pages: https://play.sweet.io/creators/{handle}.

Statistics

All stats endpoints need the stats:read scope and only return data for games you own. Daily figures are rolled up every 15 minutes (UTC days). Players are identified by player_ref, a stable pseudonymous ID per game, plus their public username; platform user IDs and contact details are never shared.

EndpointParametersReturns
GET /developer/stats/overviewdays (1–92, default 30)Per game: sessions_started, sessions_completed, player_days, new_players, total_play_ms, points_spent, max_score, status, live version
GET /developer/games/{slug}/statsfrom, to (YYYY-MM-DD, max 92 days, default last 30)totals, daily[] and all_time (below)
GET /developer/games/{slug}/stats/playerssort = best_score | plays | play_time | recent; limit ≤ 200; offsetPer player: player_ref, username, plays, accepted_plays, rejected_plays, total_play_ms, best_score, first_played_at, last_played_at, flagged
GET /developer/games/{slug}/stats/scoresfrom, to, bins (2–100)Accepted-score histogram (bins[] of from/to/count), min, max, percentiles p50/p90/p99
GET /developer/games/{slug}/stats/sessionslimit ≤ 200, before_id (paging), verdict = accepted | rejected | unverifiedRecent sessions: session_id, player_ref, username, anonymous, started_at, duration_ms, claimed_score, score, verdict, reject_reason, risk_score, input_count, consumables; next_before_id
GET /developer/games/{slug}/stats/itemsfrom, toPer item: purchases, quantity, points_spent, buyers, consumed
GET /developer/games/{slug}/leaderboardperiod = daily | weekly | all_time, limit, offsetentries[] of rank, username, score, player_ref; count
GET /developer/games/{slug}/stats/multiplayerdays (1–90, default 30)rooms[] by mode and visibility (rooms, matches, players, guests, host_changes, avg_room_seconds), matches[] by mode and status (recorded, rated, unrated, void; avg_match_seconds), abandons, reports, signed_in_players
GET /developer/games/{slug}/ratingsmode (a ranked mode), limit, offsetentries[] of rank, username, rating, games, wins, player_ref; count

Fields in /stats

FieldMeaning
sessions_startedRuns started (signed-in and guest), the main popularity measure
anon_sessions_startedRuns started by guests
sessions_completed, completion_rateRuns that called endSession, and completed ÷ started
sessions_rejected, rejection_rateCompleted runs that failed verification. A high rate with real players usually means limits are too tight or events are missing.
unique_players, new_players, returning_playersDistinct signed-in players in the range, first-time players, and players who'd played before the range
anon_unique_playersDistinct guest browsers
total_play_ms, avg_session_msPlaying time (server-measured)
avg_score, min_score, max_scoreOver accepted runs
items_purchased, points_spent, items_consumedItem economy
all_time.players, all_time.plays, all_time.play_ms, all_time.flaggedLifetime totals for signed-in players

Summarising performance (prompt for your assistant)

Using my API key in GP_API_KEY and the creator guide at https://play.sweet.io/docs/creators#stats:
1. GET /developer/stats/overview?days=30 and list my games by sessions_started.
2. For each live game: GET /stats for the last 30 days, /stats/scores, /stats/players?sort=plays&limit=20
   and /stats/items.
3. Summarise per game: popularity trend (daily sessions_started), players (unique, new, returning),
   average session length, completion and rejection rates, score distribution, top players, item sales.
4. Flag anything that needs action: rejection_rate above 5% (ask support with session IDs from
   /stats/sessions?verdict=rejected), completion_rate below 50%, falling plays.

Performance report

GET /developer/reports/performance?period=this_week[&game={slug}] answers "how are my games doing?" in one call: per game and in total, plays, signed-in players, new players, minutes played, items sold and credits earned from items and memberships, each compared with the period before (like for like: this week so far against the same days last week), plus a ready-to-use summary. period is one of today, yesterday, this_week, last_week, last_7_days, last_30_days, this_month, last_month (UTC; weeks start Monday).

Connecting an AI tool (MCP)

Creators can connect Claude Code, Codex, Copilot, Cursor, Claude, ChatGPT, Gemini or any MCP client to their account. Connected tools can build the games the creator describes (chat apps that can't run commands send the files through the server) and answer questions in plain language ("How are my Sweet games performing this week?").

Troubleshooting

SymptomFix
Game shows a blank frame on the platformAbsolute paths (/assets/...) or external resources. Use relative paths and bundle everything. Check the browser console for CSP errors.
GamePlatform.init() times out on the platformThe SDK script tag must be exactly https://play.sweet.io/sdk/v1/gp-sdk.js and load before your code.
Debug report: "claimed score ... but the event trace supports ..."An event is missing, has the wrong points, or the score is computed differently from the manifest. Make every score change correspond to a gp.event.
Debug report: "synthetic input events"Your code (or a library such as a virtual joystick) dispatches key or pointer events. Call your game's handlers directly instead.
Debug report: "only N inputs" or "no input in a scoring run"Lower min_inputs_per_minute to what the game really needs, or check that input reaches the window (the SDK listens on window in the capture phase). A run that scores with no input at all is never ranked: if your game plays itself after one tap, start the session from that tap.
Precheck: external_resource / external_networkRemove CDN links and remote fetches; download the files into the package.
Precheck warning: evalA library uses dynamic code; it'll fail under the platform's policy. Use a build without it, or confirm it falls back gracefully.
Build stays on "Waiting for your AI"Your AI tool only works while it's open. Send it the line the Studio shows, or in Claude Code keep it listening with /loop 2m and the same line.
AI tool says "this connection can't build games"It was connected for reports only. Disconnect it on the AI tools page, connect again and allow Create games and submit builds.
Submit is refused: another version is still being processedAn earlier version of the game is in review. Wait for the result, or withdraw it on the game's Builds tab, then click Submit again.
Precheck: networking_libraryThe package bundles a networking library. Remove it and send messages with gp.multiplayer.send.
Precheck: ranked_without_resultA ranked mode needs every player to call gp.multiplayer.reportResult(...) at the end of each match.
Precheck or submit: multiplayer_planOnline play needs a paid plan (Builder, Studio or Titan), and the creator is on Spawn. Upgrade under Plans and billing, or remove the manifest's multiplayer section.
The game freezes when the host leavesHandle mp.on('host', ...): when isMe, carry on as host from checkpoint. Host-run games must call mp.checkpoint(state) during the match.
Ranked button does nothing for some playersRead mp.ranked: guests, players on an old version, players in a leaver cooldown and flagged players can't play ranked. Show mp.ranked.message.
not_allowed when creating a versionAnother version is still in progress (withdraw it), or the version number isn't higher than every earlier one.

Machine-readable resources