curl -sS -X POST "$BMA_BASE_URL/v1/terminal_sessions/tsn_wi5at5l2xlf3hmcmnacvfsawnp/tickets" \
-H "x-api-key: $BMA_API_KEY" \
-H "bma-workspace-id: $BMA_PROJECT_ID" \
-H "Idempotency-Key: $(uuidgen)" \
-H "content-type: application/json" \
-d '{
"purpose": "connect"
}'{
"type": "ticket",
"id": "tkt_yyycegouoconwuyipewjumyfnd",
"purpose": "connect",
"ticket": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleGFtcGxlIjp0cnVlfQ.c2lnbmF0dXJlLWV4YW1wbGU",
"ws_url": "wss://terminal.beeos.ai/v1/relay",
"subprotocol": "bma.terminal.v1",
"permissions": [
"terminal.attach",
"terminal.input",
"terminal.resize",
"terminal.close"
],
"expires_at": "2026-11-24T07:31:12.40581Z"
}{
"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>"
}Mint a single-use ticket (purpose connect)
Mints a single-use ticket to connect to a terminal session (purpose connect, the default): open a WebSocket to ws_url with subprotocol bma.terminal.v1 and present the ticket; the first connection opens the session’s PTY on the machine (later ones reattach to the same PTY). The ticket is valid for 60 seconds and its value appears in this answer only. A paused machine is woken first and the call waits for a machine that is still starting. Only starting and running sessions take tickets; a closed or failed session is a 409 terminal_session_closed and is never reopened. Every call mints a new ticket; Idempotency-Key is not applied by this endpoint.
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. The workspace role admin, developer or operator in the session’s workspace (bma-workspace-id or anthropic-workspace-id, else the credential’s default workspace); organization owners and admins act as workspace admins. Viewers are refused.
Limits:
- Request body: at most 64 KiB.
- The ticket is single-use and valid for 60 seconds;
ttl_secondsmust be 15 to 120 but does not change that lifetime. - Waiting for a paused or starting machine: within a 20-second budget, answered at least 2 seconds before it ends.
- Rate limit: one request of the organization’s write 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 | hands_unavailable | The machine has failed or is being deleted. | Correct the request as the message describes and send it again; the same request will keep failing. |
| 400 | invalid_request_error | invalid_request | purpose is not connect or ttl_seconds is outside 15 to 120. | Correct the request as the message describes and send it again; the same request will keep failing. |
| 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, or the workspace role does not allow terminals. | Use a credential with the required role or access; retrying with the same credential will not help. |
| 409 | conflict_error | machine_executor_unavailable | The machine’s executor did not connect after the platform restarted it. | Wait for the Retry-After interval, then retry; the next use restarts the executor again. |
| 409 | conflict_error | machine_rebuilding | The machine is being rebuilt onto a new template. | Wait for the Retry-After interval, then retry. |
| 409 | conflict_error | machine_starting | The machine or its executor is still starting after the wait; retry after Retry-After. | Wait for the Retry-After interval, then retry. |
| 409 | conflict_error | machine_state_conflict | The machine is in a state that cannot be woken. | Re-read the resource, resolve the conflicting state, then send the request again. |
| 409 | conflict_error | machine_unavailable | The machine did not become ready within the wait. | Re-read the resource, resolve the conflicting state, then send the request again. |
| 409 | conflict_error | terminal_session_closed | The session is closed or failed. | Re-read the resource, resolve the conflicting state, then send the request again. |
curl -sS -X POST "$BMA_BASE_URL/v1/terminal_sessions/tsn_wi5at5l2xlf3hmcmnacvfsawnp/tickets" \
-H "x-api-key: $BMA_API_KEY" \
-H "bma-workspace-id: $BMA_PROJECT_ID" \
-H "Idempotency-Key: $(uuidgen)" \
-H "content-type: application/json" \
-d '{
"purpose": "connect"
}'{
"type": "ticket",
"id": "tkt_yyycegouoconwuyipewjumyfnd",
"purpose": "connect",
"ticket": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleGFtcGxlIjp0cnVlfQ.c2lnbmF0dXJlLWV4YW1wbGU",
"ws_url": "wss://terminal.beeos.ai/v1/relay",
"subprotocol": "bma.terminal.v1",
"permissions": [
"terminal.attach",
"terminal.input",
"terminal.resize",
"terminal.close"
],
"expires_at": "2026-11-24T07:31:12.40581Z"
}{
"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
Body
Body of a terminal ticket. purpose is optional and must be connect.
Response
The ticket; its ticket value is shown only here.
A transport-bound credential. BMA WebSocket tickets are single-use; LiveKit credentials support SDK reconnect with admission rechecked. purpose names what it opens (watch, connect; control is reserved).