curl -sS "$BMA_BASE_URL/v1/terminal_sessions/tsn_wi5at5l2xlf3hmcmnacvfsawnp" \
-H "x-api-key: $BMA_API_KEY" \
-H "bma-workspace-id: $BMA_PROJECT_ID"{
"type": "terminal_session",
"id": "tsn_wi5at5l2xlf3hmcmnacvfsawnp",
"org_id": "org_ibwqit3njkb2mwquggpsns65sx",
"project_id": "proj_mvn54w6ybm4sytmuddlydotvmt",
"machine_id": "mch_5litd6cy6bqsd6apzqg53ptiso",
"state": "running",
"shell": "/bin/bash",
"cwd": "/home/user",
"cols": 120,
"rows": 32,
"created_at": "2026-11-24T07:30:11.802546Z"
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"bma_error_code": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"bma_error_code": "<string>"
},
"request_id": "<string>"
}Retrieve a terminal session
Reads a terminal session of the request’s workspace, open or ended: its state (starting until a client first attaches, running while its PTY lives, closed or failed once it ended), its size and, once ended, when and why (closed_at, close_reason, exit_code). Reading changes nothing and never wakes the machine. A session of another workspace or organization answers 404.
Authorization: Organization API key (x-api-key: bma_org_v1_...), personal access token or OAuth access token (Authorization: Bearer ...), or a signed-in dashboard session; a user credential that is not bound to one organization names it with bma-organization-id. Any workspace role (viewer included) in the request’s workspace (bma-workspace-id or anthropic-workspace-id, else the credential’s default workspace); organization owners and admins act as workspace admins.
Limits:
- No limits specific to this endpoint.
- Rate limit: one request of the organization’s read budget (Rate limits).
Errors (besides the common errors (401 authentication, 429 rate_limited, 500)):
| Status | error.type | error.code | Cause | Fix |
|---|---|---|---|---|
| 400 | invalid_request_error | organization_required | A user credential that belongs to no single organization names none with bma-organization-id. | Correct the request as the message describes and send it again; the same request will keep failing. |
| 400 | invalid_request_error | project_required | The credential can use several workspaces and the request names none. | Correct the request as the message describes and send it again; the same request will keep failing. |
| 400 | invalid_request_error | workspace_id_conflict | bma-workspace-id and anthropic-workspace-id name different workspaces. | Correct the request as the message describes and send it again; the same request will keep failing. |
| 403 | permission_error | permission_denied | The credential cannot call this API. | Use a credential with the required role or access; retrying with the same credential will not help. |
curl -sS "$BMA_BASE_URL/v1/terminal_sessions/tsn_wi5at5l2xlf3hmcmnacvfsawnp" \
-H "x-api-key: $BMA_API_KEY" \
-H "bma-workspace-id: $BMA_PROJECT_ID"{
"type": "terminal_session",
"id": "tsn_wi5at5l2xlf3hmcmnacvfsawnp",
"org_id": "org_ibwqit3njkb2mwquggpsns65sx",
"project_id": "proj_mvn54w6ybm4sytmuddlydotvmt",
"machine_id": "mch_5litd6cy6bqsd6apzqg53ptiso",
"state": "running",
"shell": "/bin/bash",
"cwd": "/home/user",
"cols": 120,
"rows": 32,
"created_at": "2026-11-24T07:30:11.802546Z"
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"bma_error_code": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"bma_error_code": "<string>"
},
"request_id": "<string>"
}Headers
Path Parameters
Response
The terminal session.
starting until a client first attaches and the PTY opens, then running; closed once it ended (closed, exited or idle); failed when an attach found the PTY replaced (close_reason pty_recreated). closing is not used.
starting, running, closing, closed, failed Why the session ended, absent while open. closed_by_user (the close endpoint), exited (the shell exited), idle_expired (no client attached for the idle timeout), pty_recreated (the PTY was replaced, state failed), or a reason the machine reported when it ended the PTY (closed when it gave none).