# Python SDK

bsln version: `0.0.1b40`

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

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

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

## Connect

In the [Quickstart Python project](https://docs.baseline-robotics.com/index.md#3-run-a-session), verify the account the SDK uses after CLI sign-in:

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

with Client() as client:
    print(client.whoami()["name"])
PY
```

<a id="errors"></a>

`Client()` reads the [CLI connection settings](https://docs.baseline-robotics.com/cli.md#connection-settings). Pass `Client(url, token)` for an explicit connection. A `with Client()` block closes SDK-owned HTTP connections on exit. Close a borrowed `http_client` yourself. Supply either `transport` or `http_client`. The default timeout is 60 seconds per HTTP request phase.

Unsuccessful API responses raise `BslnError` with `status_code`, `detail`, and optional `code` and `request_id`. Use `transport=httpx.MockTransport(handler)` to test SDK calls with local responses.

## Sessions and connections

See [sessions and state](https://docs.baseline-robotics.com/sdk/sessions.md) for controller ownership and lifecycle. Use [streams](https://docs.baseline-robotics.com/sdk/stream-reference.md) to watch a session separately.

## Account and stations

<a id="client"></a>
<a id="clientwhoami"></a>
<a id="clientcreate_token"></a>
<a id="clienttokens-and-clientiter_tokens"></a>
<a id="clientrevoke_token"></a>
<a id="clientclose"></a>
<a id="stations"></a>
<a id="clientrobot_types"></a>
<a id="clienttasks"></a>

`client.whoami()` needs `read` and gives the user ID, name and scopes. `client.create_token(scopes, name=..., ttl_days=...)` returns the value once and can only grant scopes you hold. Use `client.tokens(limit=...)` for one page or `client.iter_tokens(page_size=...)` for all metadata. `client.revoke_token(token_id)` revokes an owned token. Check `client.robot_types()` for station types and `client.tasks()` for built-in tasks and availability.

## Collections and submission recovery

Iterators fetch all pages. If a create response was lost, retry with the same request ID and unchanged arguments. For HTTP status, error fields and replay semantics, see [requests and errors](https://docs.baseline-robotics.com/api.md#creating-an-activity-once).

## Station description

Use `session.description` or the read-only `client.session_description(session_id)` to inspect a session's robot configuration.

| Field | Value |
| --- | --- |
| `joint_order`, `joints` | Joint names in command order, with each joint's `unit`, `safe_range` and `max_velocity`. |
| `cameras` | Camera names, dimensions and frame rates. |
| `poses`, `home_name` | Named positions supported by `session.move_to`. |
| `control_hz`, `deadman_timeout_s`, `chunks` | The advertised control rate, streamed-target lifetime, chunk size, horizon and playout delay. |
