Servers

Get websocket credentials for the console and file tail

POST
/game-servers/{slice}/socket

Mints a short-lived credential for the server's live feeds. The node carries the console and the file tail on one socket, separated only by what the token permits, so this is one call for both.

A POST because it mints a credential — it reads like a read and is not one.

Connecting

Open the returned socket and authenticate in-band. There is no bearer header on the socket:

{"event": "auth", "args": ["<token>"]}

Wait for auth success before subscribing to anything. You do not need an Origin header — a missing one is accepted, which is what makes this usable from a script rather than only a browser.

The token is short-lived; expires_at says when. The socket emits token expiring about 60 seconds ahead — re-send auth with a fresh token on the same socket and any tails already running continue untouched. A token minted before the daemon last restarted is refused, so mint on demand rather than caching.

What the token can do

permissions echoes the daemon-level permissions the token carries, so you know what you hold before a frame is refused rather than after. They are derived from your key's abilities and cannot be requested:

Your key holdsThe token gains
game-servers.readwebsocket.connect — receive console output
game-servers.managecontrol.console, control.start, control.stop, control.restart
game-servers.files.readfile.read-content — required to tail a file

A read-only key therefore gets a socket it can listen on and not send through, and tailing a file needs the file-read ability even though the tail arrives over this socket rather than the file endpoints.

Tailing a file

Subscribe with tail file, whose args[0] is a JSON string:

{"event": "tail file", "args": ["{\"id\":\"log\",\"path\":\"logs/latest.log\",\"lines\":150}"]}

Every frame carries byte offsets and file identity so a disconnect is recoverable: store next_offset and inode from the last tail data you processed, and resume with start:"offset". Omitting inode is the mistake that matters — after a rotation the same offset points into a different file, and the daemon cannot tell.

Losing bytes is always announced as tail gap rather than passing silently. See the Game Servers guide for the full protocol.

Authorization

orgApiKey game-servers.read
AuthorizationBearer <token>

An organisation API key, prefixed tbk_. Create one under Organisation to API keys; the plaintext is shown once.

The scopes listed on each operation are the abilities the key must carry. They are not OAuth scopes and are not negotiated per request.

In: header

Scope: game-servers.read

Path Parameters

slice*string

The server's UUID, as returned by the list endpoint.

Formatuuid

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/game-servers/497f6eca-6276-4993-bfeb-53cbbbba6f08/socket"
{  "data": {    "socket": "wss://node-42.terabit.io:8080/api/servers/8f1c.../ws",    "token": "string",    "expires_at": "2019-08-24T14:15:22Z",    "permissions": [      "websocket.connect"    ]  },  "message": "string"}