curl -sS "$BMA_BASE_URL/v1/terminal_sessions?machine_id=mch_5litd6cy6bqsd6apzqg53ptiso" \
-H "x-api-key: $BMA_API_KEY" \
-H "bma-workspace-id: $BMA_PROJECT_ID"{
"data": [
{
"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": "terminal_session",
"id": "tsn_cdm33ffkwxaunelwig33wvy2rp",
"org_id": "org_ibwqit3njkb2mwquggpsns65sx",
"project_id": "proj_mvn54w6ybm4sytmuddlydotvmt",
"machine_id": "mch_5litd6cy6bqsd6apzqg53ptiso",
"state": "closed",
"cols": 80,
"rows": 24,
"created_at": "2026-11-24T06:02:47.11934Z",
"closed_at": "2026-11-24T06:20:03.5112Z",
"exit_code": 0,
"close_reason": "exited"
}
],
"next_page": null
}{
"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>"
}List the terminal sessions of a machine
Lists the terminal sessions of one machine in the request’s workspace, open and ended, newest first (by creation time, then ID). Pages hold limit sessions (query parameter, default 20, at most 100); pass next_page of an answer as the page query parameter for the next page, and next_page is null on the last one. order, include_archived and created_at[gte|gt|lte|lt] are validated like on other lists but do not change the answer. A machine that does not exist or has no sessions in this workspace answers an empty list; sessions of other workspaces are never listed. Listing does not wake the machine.
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:
limit: 1 to 100, default 20.- 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?machine_id=mch_5litd6cy6bqsd6apzqg53ptiso" \
-H "x-api-key: $BMA_API_KEY" \
-H "bma-workspace-id: $BMA_PROJECT_ID"{
"data": [
{
"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": "terminal_session",
"id": "tsn_cdm33ffkwxaunelwig33wvy2rp",
"org_id": "org_ibwqit3njkb2mwquggpsns65sx",
"project_id": "proj_mvn54w6ybm4sytmuddlydotvmt",
"machine_id": "mch_5litd6cy6bqsd6apzqg53ptiso",
"state": "closed",
"cols": 80,
"rows": 24,
"created_at": "2026-11-24T06:02:47.11934Z",
"closed_at": "2026-11-24T06:20:03.5112Z",
"exit_code": 0,
"close_reason": "exited"
}
],
"next_page": null
}{
"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>"
}