GET /v1/sandboxes/{sandbox_id}/pty
Opens a WebSocket attached to a new pseudo-terminal running the user's login shell (or `cmd`). Binary frames carry terminal bytes in both directions. Text frames carry JSON control messages: send `{"type": "resize", "cols": 120, "rows": 40}`; the server sends `{"type": "exit", "code": 0}` before it closes. Authenticate with the `Authorization` header or a ticket from `POST /v1/sandboxes/{sandbox_id}/ticket`.

Authentication

Bearer Token (b3os_sk_ API key or b3os_pat_ token) API Key (cookie: __Host-b3os_session) API Key (query: ticket)

Path Parameters

sandbox_id string required path
The sandbox ID (`sbx_…`).
Example: "sbx_01m5t68q1b590rj801nbzsqzkk"

Query Parameters

cols integer optional query
rows integer optional query
cmd string optional query
Command to run instead of the login shell.
cwd string optional query
ticket string optional query
A single-use stream ticket from the resource's `POST …/ticket` operation, for clients that cannot set headers (browser `WebSocket` and `EventSource`); see the `ticket` security scheme. WebSocket clients may send it as a subprotocol instead: `Sec-WebSocket-Protocol: b3os.v1, b3os.ticket.<ticket>`. Query strings are redacted from logs.

Responses

101 Switching protocols; the socket is attached to the terminal.

No response body

400 The request failed validation (`invalid_request`, `invalid_url`).
401 Missing, malformed, expired or revoked credentials (`unauthorized`).
403 Authenticated but not allowed (`forbidden`, `egress_denied`).
404 No such sandbox in this project (`sandbox_not_found`).
409 The sandbox is paused or stopped (`sandbox_not_running`).
429 A rate, concurrency or quota limit applies (`rate_limited`, `concurrency_limited`, `quota_exceeded`).
500 Something failed inside B3OS (`internal`). Retry with backoff.
502 The agent inside the microVM did not answer (`guest_unreachable`).
503 The node or the product is not available right now (`node_unavailable`, `product_unavailable`, `capacity_unavailable`).
curl -X GET 'https://beta-api.b3os.org/v1/sandboxes/sbx_01m5t68q1b590rj801nbzsqzkk/pty' \  -H 'Authorization: Bearer YOUR_API_TOKEN'
const response = await fetch('https://beta-api.b3os.org/v1/sandboxes/sbx_01m5t68q1b590rj801nbzsqzkk/pty', {  method: 'GET',  headers: {      "Authorization": "Bearer YOUR_API_TOKEN"  }});const data = await response.json();console.log(data);
import requestsheaders = {    'Authorization': 'Bearer YOUR_API_TOKEN'}response = requests.get('https://beta-api.b3os.org/v1/sandboxes/sbx_01m5t68q1b590rj801nbzsqzkk/pty', headers=headers)print(response.json())
400 Response
{  "type": "https://docs.beta.b3os.org/errors#invalid_request",  "title": "Invalid request",  "status": 400,  "code": "invalid_request",  "detail": "1 field failed validation",  "instance": "req_01m5t4yg394wegr3j4y01qb363",  "errors": [    {      "pointer": "/url",      "detail": "must be an absolute http or https URL"    }  ]}
Ask a question... ⌘I