# Sessions and state

bsln version: `0.0.1b40`

SDK source: `baseline-robotics/engineering@c8db8d9fbc8ce8e0524c5ee45cebdfcec34fc666:robotics/bsln`

Page source: `baseline-robotics/engineering@c8db8d9fbc8ce8e0524c5ee45cebdfcec34fc666:robotics/bsln/docs/customer/SDK-SESSIONS.md`

[Read on the web](https://docs.baseline-robotics.com/sdk/sessions/) | [Markdown](https://docs.baseline-robotics.com/sdk/sessions.md) | [Documentation index](https://docs.baseline-robotics.com/llms.txt)

## Start and end a session

<a id="clientstart_session"></a>
<a id="clientattach_session"></a>
<a id="clientsession-clientsessions-and-clientiter_sessions"></a>
<a id="clientstop_session"></a>
<a id="sessionstop"></a>
<a id="sessionend"></a>

Pass the approved `robot_type` and `max_occupied_s` to `client.start_session`. It creates a session and attaches a controller when your account has SDK access. The server assigns a station. For a one-session pilot, pass the assigned `request_id` as shown in [Quickstart](https://docs.baseline-robotics.com/index.md#3-run-a-session). The context asks the station to end the session on exit. Keep the session ID so you can verify the outcome after a timeout. For an existing session, `client.attach_session(session_id)` opens a controller. Exiting its context closes that connection.

<a id="attach-to-an-existing-session"></a>

Use `session.end(timeout=...)` to request shutdown and wait for confirmation. `session.stop()` and `client.stop_session(session_id)` return the session record after requesting a stop, before cleanup is confirmed. For an explicit move to the reviewed rest pose, call `session.park()` and wait for its result.

## Read the state

From the [Quickstart Python project](https://docs.baseline-robotics.com/index.md#3-run-a-session), enter your session ID:

```bash
uv run python -c '
from bsln.sdk import Client

session_id = input("Session ID: ").strip()
with Client() as client:
    print(client.session(session_id)["state"])
'
```

<a id="sessionid"></a>
<a id="sessionstate"></a>
<a id="sessiondescription"></a>
<a id="sessionwait_until_active"></a>
<a id="sessionget_joints"></a>
<a id="sessionget_state"></a>
<a id="sessionstats"></a>
<a id="sessionusage"></a>
<a id="sessionreport"></a>

| Member | What it gives you |
| --- | --- |
| `session.id`, `session.state` | The session ID and latest cached lifecycle snapshot. Read `client.session(session.id)` for the server record. |
| `session.wait_until_active(timeout=...)` | Wait for the station to accept control before sending motion. |
| `session.get_joints()` | Measured joint positions keyed by name. Arm joints use radians and grippers use 0 to 1. |
| `session.get_state(timeout=10.0, max_age_s=1.0)` | Telemetry with `requested`, `target` and `measured` joint dictionaries, plus flags, fault and receive age. Tighten `max_age_s` for newer feedback. |
| `session.stats()`, `session.usage` | SDK connection statistics and the final usage record when available. |
| `session.report()` | The ended-session report. An active session returns HTTP 409. |

Use `client.sessions()` for one page and `client.iter_sessions()` to iterate across pages. A reconnect clears cached telemetry. Read fresh feedback before planning the next action.

## Send commands

<a id="session-data-and-safety"></a>
<a id="clientdownload_session"></a>
<a id="clientestop_reset_status"></a>
<a id="clientestop_run"></a>
<a id="clientestop_session"></a>
<a id="clientreset_estop"></a>
<a id="clientrobot_types"></a>
<a id="clientsession_description-clientrun_description-clientsession_model-and-clientrun_model"></a>
<a id="clientsession_lights-and-clientset_session_lights"></a>
<a id="clientsession_report"></a>
<a id="clientsnapshot-and-sessionsnapshot"></a>
<a id="clienttasks"></a>

See [motion and emergency stop](https://docs.baseline-robotics.com/station/commands.md), [reports and observations](https://docs.baseline-robotics.com/sdk/client-data-reference.md) or [account and station methods](https://docs.baseline-robotics.com/sdk.md#account-and-stations).
