Companion apps

Server REST API

Every server ships a small HTTP API for dashboards, bots and scheduling tools. It can post announcements, list players and load, switch or unload worlds. There is also an open health endpoint and a UDP status query.

Scope. The REST API controls the server it runs on. It has no endpoints for kicking, banning, muting or reading chat. Those live in the game client and the local server console. Text chat is end-to-end encrypted, so the server can't read it anyway.

Turning it on

The API is off by default. Server settings live in config/config.xml next to the server executable. You can also override any of them with an environment variable whose name exactly matches the setting. On Linux that match is case-sensitive. Changes to these four settings need a restart.

SettingDefaultMeaning
ApiEnabledfalseStarts the listener.
ApiKeyemptyThe bearer token. If it's empty, the API stays off even when ApiEnabled is true.
ApiHostlocalhostBind address. 0.0.0.0 or :: listens on every interface.
ApiPort10667TCP port.
<ApiEnabled>true</ApiEnabled>
<ApiHost>0.0.0.0</ApiHost>
<ApiPort>10667</ApiPort>
<ApiKey>a-long-random-secret</ApiKey>

If the port is already in use, the server exits with code 69 and the message "The REST API could not listen on …". When it starts, the log line REST API started at http://host:port/api/ gives you the base URL.

  • Docker: the shipped image doesn't publish 10667. Add a port mapping, and set ApiHost=0.0.0.0, because localhost inside a container can't be reached from outside it.
  • Windows: binding to all interfaces with HttpListener normally needs administrator rights or a URL reservation (netsh http add urlacl).

Security model

  • Plain HTTP. The listener doesn't do TLS. Keep it on localhost or a private network, or put it behind a reverse proxy that terminates HTTPS. Never send the key over the open internet unencrypted.
  • One key, full control. There are no scopes. Anyone with the key can load worlds and message every player.
  • No CORS. The server sends no Access-Control-* headers and checks the key before routing, so a browser's preflight request gets a 401. A web dashboard has to call the API from its own backend. That's the right design anyway, because the key must never reach a browser.
  • Limits. At most 32 requests are handled at once; beyond that the server answers 503. Request bodies are capped at 1 MiB. There's no per-client rate limit, so add one in your proxy if you need it.

Requests and responses

Send the key as a bearer token on every request:

Authorization: Bearer a-long-random-secret
  • Bodies are JSON. The server doesn't check Content-Type, and an empty body is read as {}.
  • Responses are application/json; charset=utf-8 with Cache-Control: no-store.
  • Paths are case-sensitive and start with /api/.
StatusBodyWhen
200Route-specific; always includes "ok":true for writesSuccess
400{"error":"…"}Bad JSON or a failed field check. The message names the field.
401empty, with WWW-Authenticate: Bearer realm="basis-server"Missing or wrong key, on any path
404{"error":"not found"}, "player not found" or "world not found"Unknown route or id
405empty, with an Allow headerWrong method for the route
413{"error":"payload too large"}Body over 1 MiB
500{"error":"internal server error"}Server fault
503empty32 requests already in progress

Endpoints

POST /api/announce

Shows a server announcement to everyone connected.

{ "message": "Server restarts in 10 minutes" }

message is required: a non-empty string of up to 512 characters. The response is {"ok":true}.

POST /api/announce/{uuid}

Sends the same kind of message to one player. {uuid} is the player's identity, a did:key:… string, exactly as /api/players reports it. The body follows the same rules as above. If that player isn't connected and signed in, the response is a 404 with player not found.

GET /api/players

Lists connected players.

{
  "players": [
    {
      "netId": 3,
      "uuid": "did:key:z6Mk...",
      "displayName": "Sunny",
      "platform": "Windows",
      "position": [12.5, 0.0, -4.25]
    }
  ]
}
  • netId is the connection number for this session. It changes on every reconnect.
  • uuid is the player's identity, and it stays the same across sessions and servers. Store this one, not netId.
  • displayName and platform are empty strings when the server hasn't received them yet.
  • position is null when the server has no current position for that player.

GET /api/worlds

Lists the worlds (scenes) currently loaded. Props and avatars are not included.

{
  "worlds": [
    {
      "netId": "9f1c2e0b7a4d4e44b0c1d2e3f4a5b6c7",
      "url": "https://cdn.example.com/plaza.bee",
      "persistent": true,
      "adminLocked": true,
      "strategy": 2
    }
  ]
}

strategy is a number here: 0 is immediate, 2 is synchronized and 3 is predownload.

POST /api/worlds

Loads a world for everyone, alongside whatever is already loaded.

{
  "url": "https://cdn.example.com/plaza.bee",
  "password": "bundle-password",
  "persistent": true,
  "strategy": "synchronized"
}
FieldRules
urlRequired. An absolute https:// URL to a built content bundle.
passwordThe bundle's password. Required, unless you put it in the URL fragment (see below).
persistentOptional. Only the JSON literal true turns it on.
strategyOptional. "immediate" (default), "synchronized", "predownload", or the numbers 0, 2 or 3. Any other value returns 400.

The response is {"ok":true,"netId":"<32 hex characters>"}. Keep the netId if you want to unload this world later. Worlds loaded through the API are locked, so players can't remove them.

Password in the URL. Share links often carry the password after a # (or %23), Base64-encoded. The server splits it off and decodes it. If the fragment isn't valid Base64, it uses the text as it is. A password field, when you send one, takes priority over the fragment.

POST /api/worlds/switch

Moves everyone to a new world: an optional announcement, an optional countdown, then a synchronized load. This is the endpoint to use for scheduled events.

{
  "url": "https://cdn.example.com/stage.bee",
  "password": "bundle-password",
  "announceMessage": "Moving to the stage in 30 seconds",
  "delay": 30
}
  • url, password and persistent follow the same rules as POST /api/worlds.
  • announceMessage is optional, up to 512 characters, and is sent at once.
  • delay is a whole number of seconds from 0 to 300. null means 0.

The response returns the netId straight away, but with a delay the world doesn't appear in GET /api/worlds until the countdown ends. If the server stops first, the pending switch is cancelled.

DELETE /api/worlds/{netId}

Unloads one world. The response is {"ok":true}, or a 404 with world not found.

DELETE /api/worlds

Unloads every world and tells clients to clear their scenes. The response is {"ok":true,"unloaded":2}.

Examples

curl

curl -H "Authorization: Bearer $BASIS_API_KEY" http://127.0.0.1:10667/api/players

curl -X POST -H "Authorization: Bearer $BASIS_API_KEY" \
     -d '{"message":"Welcome to the morning meetup!"}' \
     http://127.0.0.1:10667/api/announce

C# (.NET)

using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

HttpClient http = new HttpClient();
http.BaseAddress = new Uri("http://127.0.0.1:10667/api/");
http.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("BASIS_API_KEY"));

string players = await http.GetStringAsync("players");

StringContent body = new StringContent("{\"message\":\"Doors open!\"}", Encoding.UTF8, "application/json");
HttpResponseMessage response = await http.PostAsync("announce", body);
response.EnsureSuccessStatusCode();

Python

import os, requests

API = "http://127.0.0.1:10667/api/"
HEADERS = {"Authorization": "Bearer " + os.environ["BASIS_API_KEY"]}

for p in requests.get(API + "players", headers=HEADERS, timeout=5).json()["players"]:
    print(p["displayName"], p["uuid"])

Health endpoint

Separate from the API and always on, with no key needed. Use it for uptime monitors and load balancers. Only GET is accepted.

SettingDefault
HealthCheckHostlocalhost
HealthCheckPort10666
HealthPath/health
EnableStatisticstrue: adds traffic counters to the response
HealthIncludeBSRProfilingfalse: adds a detailed bsr load block

The status is 200 while the server is up and 503 otherwise. The body looks like this:

{
  "listening": true,
  "ready": true,
  "visitors": 14,
  "capacity": 65535,
  "sent": 123456789,
  "recv": 98765432,
  "packetsSent": 4567890,
  "packetsRecv": 3456789,
  "droppedUnreliable": 0,
  "droppedVoice": 0,
  "queuePerPeer": 0,
  "voiceQueuePerPeer": 0,
  "currentTime": "2026-11-21T09:30:00.0000000Z",
  "startTime": "2026-11-20T06:00:00.0000000Z",
  "version": "58",
  "gc": { "gen0": 120, "gen1": 14, "gen2": 2, "heapMb": 182.4, "serverGc": true, "latencyMode": "SustainedLowLatency" },
  "transports": [ { "id": "litenetlib", "running": true, "peers": 14 } ]
}

version is the network protocol version, sent as a string. Clients must match it exactly. With EnableStatistics off, the response keeps only listening, ready, the times, version, gc and transports. Treat any field not shown here as informational: it may change between releases.

UDP status query

Server browsers can ask any server for its name, MOTD and player count without connecting. Send an unconnected UDP packet to the game port (default 4296). All integers are little-endian.

Query:    u32 0xBA515101 | u16 protocolVersion | u16 nonce | zero padding up to at least 384 bytes
Response: u32 0xBA515102 | u16 1 | u16 nonce | u16 online | u16 max | string name | string motd
  • Packets under 384 bytes are ignored. The padding stops the server from being used to amplify traffic.
  • Strings use LiteNetLib's NetDataWriter.Put(string) encoding. The name is at most 64 characters and the MOTD at most 256.
  • The server answers each IP at most once every 500 ms, and at most 100 queries a second in total.
  • Send your nonce and match it in the response, so you can tell which reply belongs to which query.

Local admin console

Admin tasks that aren't in the REST API, such as permissions, storage and config, go through the server's console. basisctl reaches the same console over a local Unix domain socket, for scripts on the same machine. Run basisctl /help to list commands, or basisctl attach for an interactive session. It's local only by design. Don't expose the socket over a network.