Server
Console details
Generates credentials to establish a websocket
How to connect
- Connect to the websocket address (in this example "wss://pterodactyl.file.properties:8080/api/servers/1a7ce997-259b-452e-8b4e-cecc464142ca/ws")
- Send the token to the websocket like this:
{"event":"auth","args":["eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6Ij..."]}
- Tokens last about 10-15 minutes, and the websocket will notify you once you need to send a new token with
{"event":"token expiring"}and{"event":"token expired"}
Things you can send
{"event":"auth","args":["<token>"]}# Authenticate with websocket{"event":"send stats","args":[null]}# Request stats{"event":"send logs","args":[null]}# Request logs{"event":"set state","args":["<power-action>"]}# Send power action{"event":"send command","args":["<command>"]}# Send command
Things you'll receive
{"event":"auth success"}# Upon successful websocket authentication{"event":"status","args":["offline"]}# Status updates of the server{"event":"console output","args":["[14:07:12] [Query Listener #1/INFO]: Query running on 0.0.0.0:25565"]}# Logs from server{"event":"stats","args":["{\"memory_bytes\":526626816,\"memory_limit_bytes\":588800000,\"cpu_absolute\":588.815,\"network\":{\"rx_bytes\":1126,\"tx_bytes\":1126},\"state\":\"stopping\",\"disk_bytes\":128118626}"]}# Stats from server{"event":"token expiring"}# Token is expiring soon so request a new one and send it to the websocket{"event":"token expired"}# Token has expired
GET
/api/client/servers/{server}/websocketAuthorization
ClientToken AuthorizationBearer <token>
Client API key (generated at /account/api)
In: header
Path Parameters
server*string
Server identifier (short 8-character ID)
Response Body
application/json
curl -X GET "https://pterodactyl.file.properties/api/client/servers/1a7ce997/websocket" \ -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \ -H "Accept: application/json"{
"data": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6Ij...",
"socket": "wss://pterodactyl.file.properties:8080/api/servers/1a7ce997-259b-452e-8b4e-cecc464142ca/ws"
}
}