> ## Documentation Index
> Fetch the complete documentation index at: https://docs.musterbox.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Connect a game to MusterBox end to end — register the game, install the SDK, open a session, and report a result.

This guide connects a game to MusterBox end to end: register the game, install the SDK, open a session, and report a result. It takes about ten minutes.

### Prerequisites

* A MusterBox account
* A game registered in the MusterBox console
* An SDK package for your engine — [Installing the SDK](/sdk/installation)

<Steps>
  <Step title="Register your game and create a game key">
    Register the game in the MusterBox console. The console issues a **game key** (`x-game-key`) scoped to a game and environment. The game key is public by design: it is bound to the allowed origins of the hosted game.

    <Note>
      The game key is intended for browser-hosted games. Keep it out of mobile app binaries, where it cannot be origin-locked.
    </Note>

    ```text theme={"dark"}
    Game key .......... gk_8f21c3a9...
    Environment ....... sandbox
    Allowed origins ... https://play.musterbox.org
    Scopes ............ session (required to open matches)
    ```
  </Step>

  <Step title="Install the SDK">
    <CodeGroup>
      ```bash Web (sdk-js + WebAssembly) theme={"dark"}
      # From the packaged tarball (see engines/web)
      npm install @musterbox/sdk-js @musterbox/sdk-wasm
      ```

      ```bash Unity theme={"dark"}
      # Import dist/musterbox-unity-1.0.0.tgz via Package Manager > Add package from tarball
      ```

      ```bash Godot theme={"dark"}
      # Import dist/musterbox-godot (GDExtension) — see engines/godot
      ```

      ```bash Rust / Bevy theme={"dark"}
      cargo add musterbox-sdk
      ```
    </CodeGroup>
  </Step>

  <Step title="Initialize and authenticate">
    <CodeGroup>
      ```ts Browser theme={"dark"}
      import { createMusterBox } from "@musterbox/sdk-js";

      const box = createMusterBox({
        gameId: "my-arena-game",
        gameKey: "gk_8f21c3a9...",
        environment: "sandbox",
      });

      box.addEventListener("ready", async () => {
        await box.authenticate({
          identifier: "player@example.com",
          password: "********",
        });
        console.log("authenticated:", box.getStatus());
      });
      ```

      ```rust Native theme={"dark"}
      use musterbox_sdk::{MusterBoxSdk, MusterBoxConfig};

      let config = MusterBoxConfig::from_env()?;
      let sdk = MusterBoxSdk::initialize(config)?;
      sdk.start();
      let ctx = sdk.authenticate("player@example.com", "secret")?;
      ```
    </CodeGroup>
  </Step>

  <Step title="Open a match session">
    Use a real `matchId` from the tournament you entered:

    <CodeGroup>
      ```ts Browser theme={"dark"}
      const session = await box.openSession({
        environment: "sandbox",
        matchId: 1042,
      });
      const { sessionId, token, expiresAt, context } = session;
      // context: { tournamentId, matchId, participantId, slot }
      ```

      ```rust Native theme={"dark"}
      let session = sdk.open_session(environment, match_id)?;
      ```
    </CodeGroup>

    <Important>
      The session token is single-use and expires after 10 minutes. Both participants must obtain their own session.
    </Important>
  </Step>

  <Step title="Submit the result">
    Report the final outcome. It is accepted only after a session-token-validated claim from both players.

    <CodeGroup>
      ```ts Browser theme={"dark"}
      const decision = await box.submitResult({
        environment: "sandbox",
        matchId: 1042,
        outcome: "PLAYER_A_WIN", // PLAYER_A_WIN | PLAYER_B_WIN | DRAW
      });
      // decision: { decision, matchId, reason, claimCount }
      ```

      ```rust Native theme={"dark"}
      let decision = sdk.submit_result(match_id, "PLAYER_A_WIN", board_hash_opt)?;
      ```
    </CodeGroup>
  </Step>

  <Step title="Shut down cleanly">
    <CodeGroup>
      ```ts Browser theme={"dark"}
      box.logout().finally(() => box.destroy());
      ```

      ```rust Native theme={"dark"}
      sdk.shutdown();
      ```
    </CodeGroup>
  </Step>
</Steps>

### You're connected

Next: read the [production checklist](/getting-started/production-checklist) before shipping, or go straight to the [SDK reference](/sdk/overview).
