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

# SDK overview

> Understand the script Totem injects into each published game.

export const LastVerified = ({date, source}) => <div className="totem-verified">
    <span>Last verified: {date}</span>
    {source ? <span>Source: {source}</span> : null}
  </div>;

export const StatusBadge = ({state = "available", children}) => {
  const labels = {
    available: "Available",
    "early-access": "Early access",
    planned: "Planned",
    internal: "Internal draft"
  };
  return <span className={`totem-status totem-status--${state}`}>
      {children || labels[state] || state}
    </span>;
};

<StatusBadge state="available" />

<LastVerified date="2026-08-14" source="Totem V1 contract" />

Totem injects a small browser script into a valid build. You do not install it or add its tag yourself.

## Injected tag

Totem places this tag before the closing `</body>`:

```html theme={null}
<script src="https://cdn.<USERCONTENT_DOMAIN>/sdk/v1.js" data-game="<game_id>" data-platform-origin="<platform-origin>" defer></script>
```

The script is served with the published build and connects game events to the trusted Totem shell.

## Public object

The script exposes a frozen `window.Totem` object with two methods:

* `gameOver({ score })`
* `event(name, props)`

Use feature detection if your game also runs outside Totem:

```javascript theme={null}
if (window.Totem) {
  window.Totem.gameOver({ score })
}
```

## Event path

Events travel game → SDK → `postMessage` → Totem shell → API.

The game and overlay never call the ingest API directly. The shell owns the one trusted analytics and score-write path.

## Included player features

A valid `gameOver` call can open Totem's game-over screen, save a score, update the leaderboard, and keep Play again available.

Do not send passwords, API keys, or private player information in custom event properties.
