Skip to content
Download all docs .md

Upload Key and Upload API

You upload room code with the gamefuse command. The command is a thin layer over a small HTTP API, which you can also call yourself. Both use your game's upload key.

The upload key

Where the upload key is

In the GameFuse dashboard, open your game, then Multiplayer. The key is under Upload key.

It is hidden by default. You can show it and copy it.

A key looks like this: mpk_ followed by 32 characters, each one 0 to 9 or a to f.

mpk_3f9a1c0b7d2e4f6a8b0c1d2e3f4a5b6c

What the upload key can do

It can upload room code and switch versions for that one game. It can read that game's multiplayer logs. It cannot do anything else, and it does not work for your other games.

Keep it out of your game's browser code and out of public repositories.

Regenerating the upload key

Press regenerate in the same place to get a new key. The old key stops working at once. Update it wherever you stored it, such as your build server.

Giving the key to the command

Put it in a file called .env in your project folder:

# .env  (keep it out of git)
GAMEFUSE_UPLOAD_KEY=mpk_3f9a1c0b7d2e4f6a8b0c1d2e3f4a5b6c
GAMEFUSE_GAME_ID=123

gamefuse multiplayer init makes this file and adds it to your .gitignore. The command reads .env from the folder you run it in, or the nearest folder above it, up to the top of your git project.

Or pass it each time with --key:

gamefuse multiplayer deploy --key mpk_3f9a1c0b7d2e4f6a8b0c1d2e3f4a5b6c

The gamefuse command

Install it with npm i -g gamefuse.

Command What it does
gamefuse multiplayer init --game-name <name> --game-mode <mode> --game <id> Makes the folder <name>-<mode>-gamefuse-multiplayer with room.js (a small working example), gamefuse-room.d.ts, AGENTS.md and multiplayer.json. --game-mode defaults to default.
gamefuse multiplayer validate Bundles your room code into one file and checks it. Nothing is uploaded.
gamefuse multiplayer deploy Checks your room code, uploads it as a new version of the folder's game mode, and makes it live.
gamefuse multiplayer deploy --no-activate Uploads a new version without making it live.
gamefuse multiplayer deploy --notes "..." Adds a note to the version.
gamefuse multiplayer deploy --game-mode <name> Uploads to that game mode instead of the folder's.
gamefuse multiplayer list Lists your versions and the mode of each, across all modes. Add --game-mode <name> for one mode only.
gamefuse multiplayer activate <version> Makes that version live. Use it to go back to an older version.
gamefuse multiplayer logs Shows what your room code logged. Add --follow to keep watching.

These work on every command:

Option Meaning
--key <key> The upload key. Otherwise it is read from GAMEFUSE_UPLOAD_KEY in .env or your environment. One key works for every game mode of the game.
--game <id> The game's ID. Otherwise it is read from GAMEFUSE_GAME_ID, then gameId in multiplayer.json.
--dir <folder> Which multiplayer folder to use, when there is more than one next to you. Without it, the command uses the folder you are in, or the only *-gamefuse-multiplayer folder next to you.
--json Print the result as JSON, for scripts.

The exit code is 0 when the command worked.

Settings in .env

The command reads these from .env so you do not type them each time:

Name What it is
GAMEFUSE_UPLOAD_KEY The game's upload key. The older name GAMEFUSE_MULTIPLAYER_KEY also works.
GAMEFUSE_GAME_ID The game's ID. VITE_GAMEFUSE_GAME_ID also works, so a Vite project can keep one .env.

The order is: options like --key first, then variables set in your terminal or build server, then .env, then multiplayer.json. Empty lines in .env count as not set.

multiplayer.json

gamefuse multiplayer init writes multiplayer.json into the folder it makes.

{
  "gameName": "pong",
  "gameMode": "superpong",
  "gameId": 123,
  "entry": "room.js"
}
Setting Meaning
gameName The name you gave --game-name.
gameMode The game mode this folder uploads to: the queue name players join.
gameId Your game's ID. It is 0 if you left out --game; put it in before deploying.
entry The file your room code starts from, relative to this folder. The command follows its imports and bundles everything into one file.

Going back to an older version

gamefuse multiplayer list
gamefuse multiplayer activate 6

Versions and their statuses

Each upload is a version of one game mode. Versions are numbered 1, 2, 3 and so on across the whole game. Each mode has one live version at a time, and making a version live only replaces the live version of its own mode. One upload key covers every mode of the game.

Status Meaning
uploaded Stored, but not yet checked. It is not live.
checked Passed the check. It is not live.
active The live version of its mode.
retired Was live, and has been replaced by another version.
rejected Failed the check. It is kept so you can see it in the list, but it cannot be made live.

The upload API

Use this if you script uploads yourself instead of using the gamefuse command. All addresses below start with https://gamefuse.co.

Every call needs your upload key in a header:

multiplayer-upload-key: mpk_3f9a1c0b7d2e4f6a8b0c1d2e3f4a5b6c

Every call returns JSON. An error is { "error": "plain words" } with a 4xx or 5xx status.

Status Meaning
401 The upload key is missing or wrong.
403 The upload key belongs to a different game than game_id.

The examples below expect the key in the shell variable GAMEFUSE_UPLOAD_KEY and use game ID 123.

Upload a version

POST /api/v3/multiplayer/deployments

Field Meaning
game_id Your game's ID.
code Your whole room code, as one string. It must be one file with nothing left to import. At most 5 MB.
notes Optional. A note for yourself.
mode Optional. The game mode this version is for: the queue name players join, such as "superpong". Lowercase letters, numbers, - and _, up to 40 characters. Leave it out for "default".
activate Optional. true makes the version live if it passes the check.

The room code has to go inside a JSON string. jq does that for you:

jq -Rs '{game_id: 123, mode: "superpong", code: ., notes: "faster ball", activate: true}' dist/room.js \
  | curl -sS -X POST https://gamefuse.co/api/v3/multiplayer/deployments \
      -H "multiplayer-upload-key: $GAMEFUSE_UPLOAD_KEY" \
      -H "Content-Type: application/json" \
      -d @-

Here dist/room.js is your room code as one file. If your room code has no imports, you can upload your folder's room.js as it is. Otherwise bundle it first, for example with esbuild:

npx esbuild pong-superpong-gamefuse-multiplayer/room.js --bundle --format=esm --outfile=dist/room.js

A stored version comes back with status 201:

{
  "id": 41,
  "version": 7,
  "sha256": "9f2c1a...",
  "size_bytes": 18234,
  "status": "active"
}

status tells you what happened:

status Meaning
active It passed the check and is now live.
checked It passed the check. It is not live, because you did not send activate.
uploaded The multiplayer server could not be reached to check it. It is stored but not live. The reply also has a "warning" that says so. It is checked when you activate it.
{
  "id": 41,
  "version": 7,
  "sha256": "9f2c1a...",
  "size_bytes": 18234,
  "status": "uploaded",
  "warning": "..."
}

Things that go wrong:

Status When Reply
422 The room code failed the check. The version is kept with status rejected. { "error": "...", "problems": ["..."] }
422 code is missing. { "error": "..." }
413 code is over 5 MB. { "error": "..." }

problems is a list of what the check found, one line each.

List versions

GET /api/v3/multiplayer/deployments?game_id=123

curl -sS "https://gamefuse.co/api/v3/multiplayer/deployments?game_id=123" \
  -H "multiplayer-upload-key: $GAMEFUSE_UPLOAD_KEY"
{
  "deployments": [
    {
      "id": 41,
      "version": 7,
      "mode": "superpong",
      "sha256": "9f2c1a...",
      "size_bytes": 18234,
      "status": "active",
      "notes": "faster ball",
      "created_at": "2026-11-29T14:04:00.000Z"
    },
    {
      "id": 38,
      "version": 6,
      "mode": "superpong",
      "sha256": "0b7d2e...",
      "size_bytes": 18101,
      "status": "retired",
      "notes": null,
      "created_at": "2026-11-27T09:12:00.000Z"
    }
  ],
  "active_versions": { "default": 3, "superpong": 7 },
  "active_version": 3
}

The newest version is first. active_versions gives the live version of every mode. active_version is the live version of the default mode, or of the one mode you asked for with ?mode=superpong; it is null when nothing is live. Add &mode=superpong to list one mode only.

Make a version live, or go back to an older one

POST /api/v3/multiplayer/deployments/:id/activate

:id is the version's id from the list, not its version number.

curl -sS -X POST https://gamefuse.co/api/v3/multiplayer/deployments/38/activate \
  -H "multiplayer-upload-key: $GAMEFUSE_UPLOAD_KEY" \
  -H "Content-Type: application/json" \
  -d '{"game_id": 123}'

Status 200:

{
  "id": 38,
  "version": 6,
  "sha256": "0b7d2e...",
  "size_bytes": 18101,
  "status": "active"
}

The version that was live becomes retired.

Status When
422 That version is rejected. A rejected version cannot be made live.
503 That version has not been checked yet, and the multiplayer server could not be reached to check it. Nothing changes. Try again.

Read the logs

GET /api/v3/multiplayer/logs?game_id=123&limit=200

curl -sS "https://gamefuse.co/api/v3/multiplayer/logs?game_id=123&limit=200" \
  -H "multiplayer-upload-key: $GAMEFUSE_UPLOAD_KEY"
{ "lines": [ { "at": ..., "room": ..., "level": ..., "text": "saved a point for 9041" } ] }
Field Meaning
at When the line was written.
room The room it came from.
level How serious the line is.
text The line itself.

If the multiplayer server cannot be reached, you get status 503 and { "error": "..." }.

Calls a browser makes

The client library makes these two calls for you. They are here for anyone not using it. They do not use the upload key.

Make a guest player

POST /api/v3/users/guest

Send your game's ID and API token.

curl -sS -X POST https://gamefuse.co/api/v3/users/guest \
  -H "Content-Type: application/json" \
  -d '{"game_id": 123, "game_token": "your-game-api-token"}'
{
  "id": 9041,
  "username": "Guest-4821",
  "authentication_token": "abc123",
  "guest": true
}

This is limited to 10 a minute for each IP address. Beyond that you get status 429.

Keep the authentication_token and use it again next time, so one person stays one guest.

Get a ticket

POST /api/v3/multiplayer/tickets

Send the player's authentication_token in the authentication-token header. It can be a guest's token or a signed-in player's.

curl -sS -X POST https://gamefuse.co/api/v3/multiplayer/tickets \
  -H "authentication-token: abc123"
{
  "ticket": "eyJhbGciOiJIUzI1NiJ9...",
  "host_url": "wss://...",
  "expires_in": 60
}
Field Meaning
ticket The pass the player joins a room with.
host_url The address of the multiplayer server.
expires_in How many seconds the ticket lasts: 60.

If multiplayer is switched off for the game, you get status 403 and { "error": "..." }.