# Register a server

> Register a game server with the Cmdr bridge, report what it can do and publish its Cmdr command catalogue.

The first call a game server makes to the Cmdr bridge. It tells Bloxlytics that the server is online, which bridge features it supports, and which Cmdr commands are registered in it. The response says whether the bridge is turned on for the project and how long polls are held.

After a successful hello, the server starts [polling for commands](https://docs.bloxlytics.app/api/bridge/poll). The Luau bridge waits 3 seconds after starting (so your game can register its Cmdr commands first), then sends hello, and sends it again every 300 seconds while it runs so the command catalogue stays current. If hello fails, it retries after 5 seconds, doubling the wait up to 120 seconds.

All bridge endpoints use the project's **bridge key** and [replay protection](https://docs.bloxlytics.app/api/authentication#replay-protection-for-the-bridge). The protocol is described end to end in [Cmdr bridge](https://docs.bloxlytics.app/sdk/cmdr-bridge).

## Headers

- `Content-Type` (string, header, required): `application/json`.

- `Authorization` (string, header, required): `Bearer ` followed by the project's bridge key, `bxb_…`. A write key is refused.

- `X-Bloxlytics-Project` (string, header, required): The experience's Universe ID (`game.GameId`). Legacy UUID project IDs are also accepted.

- `X-Bloxlytics-Timestamp` (string, header, required): The current Unix time in seconds. Must be within 120 seconds of Bloxlytics' clock.

- `X-Bloxlytics-Nonce` (string, header, required): A new random value for this request: 16 to 64 characters from `A–Z a–z 0–9 - { }`. Never reuse one.

## Body

At most 2 MB.

- `protocol` (number, body, required): The bridge protocol version. Must be `1`.

- `version` (string, body, required): The bridge client's version, up to 20 characters, for example `1.0.0`.

- `jobId` (string, body, required): The server's id, up to 64 characters: `game.JobId`, or the `studio-…` key the analytics SDK uses in Studio. Use the same value as `server.jobId` in [ingest](https://docs.bloxlytics.app/api/ingest/send-events) so analytics, presence and commands refer to the same server.

- `placeId` (integer, body, required): `game.PlaceId`. A whole number, `0` or more.

- `cmdrVersion` (string, body): The Cmdr version, up to 20 characters. Accepted but not currently used.

- `capabilities` (string[], body, required): What this server's bridge can do. Up to 10 values from the list below; any other value is refused. A server counts as running the bridge (and can be sent commands) when the list includes `cmdr` or `kick`.  | Value | Meaning | | --- | --- | | `cmdr` | Runs registered Cmdr commands | | `kick` | Can kick a player | | `warn` | Can show a player a warning (the game supplied an `OnWarn` handler) | | `announce` | Can show a server-wide announcement (the game supplied an `OnAnnounce` handler) | | `presence` | Reports the players in the server on each poll | | `executor` | Can run a command as the issuing team member's own player when they're in the server |  The Luau bridge always sends `cmdr`, `presence` and `executor`, adds `kick` unless `AllowKick = false`, and adds `warn` and `announce` when their handlers are set.

- `commands` (Command[], body, required): The Cmdr commands registered in this server, up to 500. Send `[]` if there are none.  Each command is saved for the project by `name`. A command that's already known has its aliases, description, group, arguments and `allowed` replaced with what you send. Commands you leave out aren't deleted.  **Command**
  
  - `name` (string, body, required): The command name, 1 to 64 characters.
  
  - `aliases` (string[], body, default []): Other names for the command, up to 20, each up to 64 characters.
  
  - `description` (string, body): Up to 512 characters.
  
  - `group` (string, body): The command's Cmdr group, up to 64 characters, for example `DefaultAdmin`. Used for per-role group restrictions.
  
  - `args` (Argument[], body, default []): The command's arguments in order, up to 32. Bloxlytics uses them to check the structure of a command line before queuing it; Cmdr checks the types in the game.  **Argument**
    
    - `name` (string, body, required): Up to 64 characters.
    
    - `type` (string, body, required): The Cmdr type name, up to 64 characters, for example `player`, `number`, `integers` or `string`.
    
    - `description` (string, body): Up to 256 characters.
    
    - `optional` (boolean, body): `true` when the argument can be left out.
    
    - `default` (string | number | boolean, body): The default value, if the argument has one.
    
    - `dynamic` (boolean, body): `true` when Cmdr defines the argument with a function, so its shape is only known at run time. Dynamic arguments are never treated as required.
  
  - `allowed` (boolean, body, default true): Whether this server lets Bloxlytics run the command. The Luau bridge sends `false` for commands whose group isn't in `AllowedGroups`. Bloxlytics refuses to queue a command marked `false`.

- `types` (string[], body, default []): Custom Cmdr type names, up to 200, each up to 64 characters. Accepted but not currently used.

- `allowSystemCommands` (boolean, body, default true): `false` when the server only runs Cmdr commands as a verified team member's player who is in this server, never in the system context. Bloxlytics then won't send a Cmdr command to this server unless the issuer is in it. See [Cmdr bridge security](https://docs.bloxlytics.app/sdk/cmdr-bridge/security).

- `studio` (boolean, body, default false): `true` for a Studio session. Studio servers are only sent commands when someone picks them explicitly.

- `tags` (object, body, default {}): Server tags, such as `{ "map": "Forest" }`: up to 16, names starting with a letter then letters, digits, spaces, `_ . -` (up to 32 characters), values up to 64 characters. Invalid tags fail the request with `400`.

## Response

`200 OK`. The server is now shown as online (as a bridge server, if `capabilities` includes `cmdr` or `kick`), and its player list is empty until its next [poll](https://docs.bloxlytics.app/api/bridge/poll).

- `ok` (boolean, required): Always `true`.

- `enabled` (boolean, required): Whether the bridge is turned on in the project's SDK configuration. When `false`, don't poll: Bloxlytics won't queue commands for the project. The Luau bridge stops after a hello that returns `false`.

- `pollHoldSeconds` (integer, required): How long a [poll](https://docs.bloxlytics.app/api/bridge/poll) is held open when there are no commands. Currently `20`. Set your HTTP timeout above this.

- `groups` (object, required): The Cmdr groups each Bloxlytics role may run, from the project's SDK configuration: optional keys `owner`, `admin` and `developer`, each a list of group names. `{}` when no restriction is set. Bloxlytics enforces this itself when someone queues a command; it's returned for information.

**Request example**

```bash cURL
curl -X POST https://api.bloxlytics.app/v1/bridge/hello \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer bxb_…" \
  -H "X-Bloxlytics-Project: <universe id>" \
  -H "X-Bloxlytics-Timestamp: $(date +%s)" \
  -H "X-Bloxlytics-Nonce: $(uuidgen)" \
  -d '{
    "protocol": 1,
    "version": "1.0.0",
    "jobId": "<job id>",
    "placeId": 1234567890,
    "capabilities": ["cmdr", "presence", "executor", "kick"],
    "commands": [
      {
        "name": "give",
        "aliases": ["g"],
        "description": "Give a player coins.",
        "group": "Admin",
        "args": [
          { "name": "player", "type": "player" },
          { "name": "amount", "type": "integer", "optional": true, "default": 100 }
        ],
        "allowed": true
      }
    ],
    "types": [],
    "allowSystemCommands": true,
    "studio": false,
    "tags": { "map": "Forest" }
  }'
```

**Response example**

```json 200
{
  "ok": true,
  "enabled": true,
  "pollHoldSeconds": 20,
  "groups": { "developer": ["Moderation"] }
}
```

```json 400
{ "error": { "code": "invalid_payload", "message": "capabilities.0: Invalid option: expected one of \"cmdr\"|\"kick\"|\"warn\"|\"announce\"|\"presence\"|\"executor\"" } }
```

```json 401
{ "error": { "code": "stale_request", "message": "Request timestamp is outside the allowed window." } }
```

```json 401 replayed
{ "error": { "code": "replayed", "message": "Nonce already used." } }
```
