Skip to main content
GET
Attach to a PTY session over WebSocket
Attach to a PTY session over WebSocket.

Endpoint

Use the WebSocket endpoint on the sandbox proxy host:

Authentication

You must provide the PTY token returned from Create PTY Session. Tensorlake accepts the token in either place:
  • Preferred: X-PTY-Token: <token>
  • Backward-compatible fallback: ?token=<token>
The header form is preferred because query parameters are more likely to appear in access logs.

WebSocket Protocol

After connecting, send a binary READY frame immediately so Tensorlake can flush any buffered output. For an end-to-end example that creates the session, sends READY, runs a command, reads output, and closes cleanly, see PTY Sessions.

Client-to-server opcodes

Server-to-client opcodes

Example Connection

Header-based token:
Query-string token:

Connection Semantics

  • If the token is invalid, Tensorlake returns 403 Forbidden with code INVALID_TOKEN.
  • If the session does not exist, Tensorlake returns 404 Not Found with code SESSION_NOT_FOUND.
  • When the process exits, Tensorlake sends the 0x03 exit frame and then closes the WebSocket with reason exit:<code>.
  • If the PTY session is terminated while the socket is open, Tensorlake closes the WebSocket with code 1001 and reason session terminated.
  • If you do not send READY, Tensorlake buffers output up to 1 MB before disconnecting the client.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

X-PTY-Token
string

Preferred PTY session token header for WebSocket authentication.

Path Parameters

session_id
string
required

The PTY session identifier.

Query Parameters

token
string

Optional PTY token. Prefer the X-PTY-Token header instead of the query string.

Response

WebSocket upgrade successful