# Authentication

> How game servers identify their project and prove it with a write or bridge key, how bridge requests are protected against replay, and how shared dashboard tokens work.

Every game-server request names a project and carries a key for it. The bridge endpoints also carry a timestamp and a single-use nonce. Public endpoints need no credentials, except shared dashboards, where the token in the URL is the credential.

| Endpoints | Project header | Key | Replay headers |
| --- | --- | --- | --- |
| `POST /v1/ingest`, `GET /v1/config` | Required | Write key, `bxw_…` | No |
| `POST /v1/bridge/*` | Required | Bridge key, `bxb_…` | Required |
| `GET /api/public/dashboards/:token…` | No | Share token, in the path | No |
| `GET /api/sdk/:file`, `GET /api/health` | No | None | No |

## The project header

```http
X-Bloxlytics-Project: <universe id>
```

A Bloxlytics project is one Roblox experience, and its project ID is the experience's **Universe ID**. A running game server already knows it as `game.GameId`, which is why the Luau SDK fills this header in for you.

The API accepts:

- **A Universe ID**: a positive whole number of 1 to 16 digits with no leading zero, such as `<universe id>`. Surrounding spaces are ignored.
- **A legacy project ID**: projects created before project IDs were Universe IDs had a UUID (`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`, hexadecimal, any case). Older SDK installs still send it, and the API maps it to the right project. New installs should send the Universe ID.

A Place ID is not a Universe ID, and the API doesn't accept one. The project's Universe ID is shown as **Project ID** under **Keys** on the project's **SDK** page.

## Project keys

Each project has two keys. You find both on the project's **SDK** page, under **Keys**, if your role has the **Edit project settings and SDK keys** permission.

| Key | Prefix | Used for | Can it read data? |
| --- | --- | --- | --- |
| **Write key** | `bxw_` | `POST /v1/ingest`, `GET /v1/config` | No. It can only send events and fetch the SDK's own remote config. |
| **Bridge key** | `bxb_` | `POST /v1/bridge/*` | No. It can register a server, receive commands addressed to that project's servers and report their results. |

Send the key as a bearer token:

```http
Authorization: Bearer bxw_…
```

The scheme must be written exactly `Bearer` followed by one space. Keys are the prefix plus 32 URL-safe characters (`A–Z`, `a–z`, `0–9`, `-`, `_`).

The two keys aren't interchangeable. A write key sent to a bridge endpoint, or a bridge key sent to `/v1/ingest`, fails with `401 unauthorized` and the message `Invalid project key.`

Neither key is a Roblox Open Cloud key, and neither can touch your DataStores, bans or anything else on Roblox. Open Cloud keys are connected separately in the dashboard and never leave Bloxlytics.

### Keep keys out of client code

Keys are meant for server scripts only. Store them as experience secrets (Creator Hub → your experience → **Secrets**, for example `bloxlytics_write_key` and `bloxlytics_bridge_key`, restricted to `api.bloxlytics.app`) and read them with `HttpService:GetSecret`; the SDK accepts a `Secret` directly. Never put a key in a `LocalScript`, a `ReplicatedStorage` module or anything else that's sent to players. See [Configuration](https://docs.bloxlytics.app/sdk/configuration).

The write key is lower-risk than it looks: someone who has it can send fake events into your project, but can't read anything. The bridge key matters more, because a server holding it receives commands. Commands still only run through the game's own Cmdr permission hooks; see [Cmdr bridge security](https://docs.bloxlytics.app/sdk/cmdr-bridge/security).

### How keys are checked and stored

- Bloxlytics keeps a SHA-256 hash of each key to check requests against, and compares hashes in constant time.
- The key itself is also stored, encrypted, so the **Keys** section can show it to you again. Each time someone opens it, the view is recorded in the [audit log](https://docs.bloxlytics.app/workspaces/audit-log).
- A missing header, a project ID the API can't read, or a missing key returns `401` with the message `Missing project id or key.` A wrong key, a deleted project or the wrong kind of key returns `401` with `Invalid project key.` The API doesn't say which part was wrong.

### Rotating a key

On the project's **SDK** page, under **Keys**, choose **Rotate write key** or **Rotate bridge key** (the refresh button beside each key), then confirm with **Rotate key**.

> **Warning:** The old key stops working at once. Servers still using it get `401` on every request. For the write key, the SDK drops each rejected batch, so events from those servers are lost until the servers have the new key. For the bridge key, remote commands stop working on those servers.

If you store the key as an experience secret, update the secret, then restart or migrate servers so they read it again. If the key is in a script, publish the place with the new key. Rotations are recorded in the [audit log](https://docs.bloxlytics.app/workspaces/audit-log). Rotate a key whenever you think it has leaked.

## Replay protection for the bridge

Every `POST /v1/bridge/*` request carries two extra headers:

```http
X-Bloxlytics-Timestamp: 1767225600
X-Bloxlytics-Nonce: 8C6F1C2E-6B7B-4E0A-9D3F-2A1B5C4D7E9F
```

| Header | Rule |
| --- | --- |
| `X-Bloxlytics-Timestamp` | The current Unix time in seconds. It must be within **120 seconds** of Bloxlytics' clock, either way. |
| `X-Bloxlytics-Nonce` | A fresh random value for every request: 16 to 64 characters from `A–Z`, `a–z`, `0–9`, `-`, `{` and `}`. A GUID from `HttpService:GenerateGUID()` fits. |

Bloxlytics remembers each nonce, per project, for 250 seconds: longer than the whole timestamp window. A request that reuses a nonce in that time is refused, and a request older than the window is refused by its timestamp. Together, a captured request can't be sent again.

The checks run in this order, after the key has been accepted:

| Failure | Status | Code | Message |
| --- | --- | --- | --- |
| Timestamp missing, not a number, or more than 120 s off | `401` | `stale_request` | `Request timestamp is outside the allowed window.` |
| Nonce missing or not 16–64 allowed characters | `401` | `bad_nonce` | `Missing nonce.` |
| Nonce already used | `401` | `replayed` | `Nonce already used.` |

The nonce is used up as soon as it passes, even if the request then fails validation or a rate limit. Generate a new one for every attempt, including retries.

> **Note:** Bridge requests are not signed: there is no HMAC over the body. The bearer key proves who is calling, HTTPS keeps the request private and unaltered in transit, and the timestamp and nonce stop replays. The Luau bridge sends `os.time()` as the timestamp and `HttpService:GenerateGUID(false)` as the nonce.

The ingest and config endpoints don't use these headers. Retrying an ingest batch is safe without them because events are deduplicated by their `id`; see [Send events](https://docs.bloxlytics.app/api/ingest/send-events#deduplication).

## Share tokens

A shared dashboard link looks like `https://dash.bloxlytics.app/share/<token>`. The token is the only credential: anyone with the link can view the dashboard, and no one needs to sign in.

- Tokens are 32 URL-safe random characters, generated when someone chooses **Create link** in a dashboard's sharing dialog. The token is shown once; Bloxlytics keeps only its SHA-256 hash.
- A link expires after the period chosen when it was made (1, 7, 30, 90 or 365 days, or never), and can be revoked at any time. A dashboard can have up to 10 active links.
- A link only works while the dashboard is shared with the project. Making the dashboard private again stops every link to it.
- Shared links are read-only and never show individual players.

The API side is described in [Shared dashboard](https://docs.bloxlytics.app/api/public/shared-dashboard). For creating and managing links, see [Dashboards](https://docs.bloxlytics.app/analytics/dashboards).

## Related

- [Errors](https://docs.bloxlytics.app/api/errors) lists every `401` code and what the SDK does with it.
- [Security and privacy](https://docs.bloxlytics.app/security) covers how Bloxlytics protects keys and data, and how to [report a security issue](https://docs.bloxlytics.app/security#reporting-issues).
