DP Code supports optional token-based authentication for its WebSocket endpoint. When no token is configured, the server accepts all incoming connections. When a token is set, every WebSocket connection must present it or the server rejects the upgrade. Authentication is transport-level — it controls access to the WebSocket connection itself. It is not a user account system.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Emanuele-web04/dpcode/llms.txt
Use this file to discover all available pages before exploring further.
Enabling authentication
Start the server with--auth-token or set the T3CODE_AUTH_TOKEN environment variable:
- CLI flag
- Environment variable
Connecting with a token
Pass the token as atoken query parameter on the WebSocket URL:
AuthError before the connection opens.
How it works
Server starts with a token configured
You pass
--auth-token <token> or set T3CODE_AUTH_TOKEN. The server stores the token in memory and marks authentication as required.Client initiates a WebSocket upgrade
The client connects to
/ws and includes ?token=<token> in the URL query string.Server validates the token
The server reads the
token query parameter and compares it to the configured value. A mismatch results in an AuthError and the upgrade is rejected.When no token is configured
If you start the server without--auth-token, authentication is disabled and all WebSocket connections are accepted without credentials. This is the default behavior and is appropriate for local-only use.
Security recommendations
Restrict the bind interface
Use
--host 127.0.0.1 to accept connections from the local machine only. Combine with a reverse proxy (nginx, Caddy) when you need remote access over HTTPS/WSS.Always set a token for remote access
Any time the server is reachable outside localhost, set
--auth-token with a strong random value. Without it, anyone who can reach the port has full access to your agent sessions.Use a trusted network
Prefer binding to a Tailscale or VPN IP rather than
0.0.0.0. This limits the attack surface to devices on your private network.Rotate the token when needed
Restart the server with a new
--auth-token value to invalidate all existing connections. There is no token rotation API — a server restart is required.Related
- Running the server — CLI flags and startup options
- Environment variables —
T3CODE_AUTH_TOKENand other variables - WebSocket API overview — Protocol details and authentication flow