# Lifecycle and realtime

bsln version: `0.0.1b40`

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

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

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

<a id="contract-maintenance"></a>

Sessions can be `starting`, `active`, `ended` or `failed`. A successful stop request can precede station cleanup. After a timeout, failed shutdown or lost connection, read the session and confirm the station is available. Where present, check `cleanup.state`, `feedback_fresh` and `shutdown_verified`.

## Check your session status

Enter your session ID and a read-scoped token for the public API at the prompts:

```bash
bash -c '
read -r -p "Session ID: " session_id || exit 1
[[ $session_id =~ ^ses_[[:alnum:]_-]+$ ]] || { printf "%s\n" "Enter a valid session ID." >&2; exit 1; }
read -r -s -p "API token: " api_token || exit 1 &&
printf "\n" >&2 &&
[[ -n $api_token ]] &&
printf "Authorization: Bearer %s\n" "$api_token" | curl -fsS -H @- "https://api.baseline-robotics.com/v1/sessions/$session_id"
'
```

## Session billing

For an account with approved billed SDK sessions, use `bsln get billing --json` to check the balance. For a quote, use `bsln check quote` with `--kind session` and the same robot type and duration as the session you plan to start. Compare `maximum_credits` with `available_credits` for the exact robot type and duration. Starting the session reserves the maximum and idle time counts. Read `billing` on the session for accrued credits and final accounting.

## Reset your own E-stop

On your ended session, call `GET /v1/sessions/{id}/estop-reset` with `read` scope. If `eligible` is true and the station is safe, send `{"fault_id":"EXACT_CURRENT_FAULT_ID"}` to the same route with `POST` and `control` scope. The server checks the fault and waits for the station to acknowledge the reset. Start a new session after success. After a timeout, recheck the status before proceeding.

## Realtime streams

Open `/v1/sessions/{id}/stream` with `control` or `/v1/sessions/{id}/watch` with `read`. Watchers cannot send motion or keep a session alive. Closing a controller that sent motion requests a hold. See [reconnect behavior](https://docs.baseline-robotics.com/station/commands.md#when-the-connection-drops).

Send a bearer header. Set `frames=0` for telemetry only or `frames=1` for camera delivery. Acknowledge each received frame with `{"type":"ack"}`. MessagePack camera payloads carry JPEG bytes. The [event schema](https://docs.baseline-robotics.com/api/events.json) lists message fields. Read the session after a disconnect to recover current state.
