POST

Authorizations

x-api-key
string
header
required

Headers

bma-workspace-id
string

Project scope. Required when the API key can access more than one project. Also accepted as anthropic-workspace-id; headers sent together must agree, otherwise the request is a 400 workspace_id_conflict.

Path Parameters

terminal_session_id
string
required

ID of the terminal session to close (tsn_ followed by 26 base32 characters). An ID of another workspace or organization, or one that is not a tsn_ ID, answers 404.

Response

The closed terminal session.

type
string
required

Always terminal_session.

Allowed value: "terminal_session"
id
string
required

Terminal session ID (tsn_...).

Pattern: ^tsn_[a-z2-7]{26}$
org_id
string
required

The organization the session belongs to (org_...).

Pattern: ^org_[a-z2-7]{26}$
project_id
string
required

Project ID (proj_...).

Pattern: ^proj_[a-z2-7]{26}$
machine_id
string
required

Machine ID (mch_...).

Pattern: ^mch_[a-z2-7]{26}$
state
enum<string>
required

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.

Available options:
starting,
running,
closing,
closed,
failed
created_at
string<date-time>
required

When the session was opened (RFC 3339, UTC).

shell
string

The shell the create request asked for; absent when it named none.

cwd
string

The working directory the create request asked for; absent when it named none.

cols
integer<int32>

Terminal width in columns at open.

rows
integer<int32>

Terminal height in rows at open.

closed_at
string<date-time>

When the session ended; absent while it is open.

exit_code
integer<int32>

Exit status of the shell when it exited on its own (close_reason exited) and was not killed by a signal; absent otherwise.

close_reason
string

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).