Dashboard Access
Last updated on November 23, 2026
You can call the TofuPilot API from a phase or a plug to read or write workspace data during a test.
TofuPilot Framework passes a ready-made tofupilot.v2.TofuPilot client to any phase or plug that names dashboard as a parameter. The client acts as the identity the CLI is logged in with: the station, or you on a development machine, whether or not the run uploads. There is no API key to create and nothing to declare in procedure.yaml.
def allocate_serials(dashboard, log):
dashboard.units.create(
serial_number="AAAVTL26410001",
part_number="ENS0000120",
revision_number="A",
metadata={"label_status": "pending"},
)
log.info("Serial number reserved")You can use it when a test needs workspace state as an input: reserving a serial number, checking that a previous run of a unit passed, looking up a sub-unit, or writing metadata on another unit. The framework uploads the run, its measurements and attachments without it.
Phase
You can add dashboard to a phase's parameters, like log or unit.
from tofupilot.v2 import TofuPilot
def check_previous_run(dashboard: TofuPilot, unit):
me = dashboard.identity.whoami()
...The client is built once per worker process and shared by its phases. Every method of the Python SDK is available, and the server applies the identity's permissions exactly as for a direct SDK call.
The TofuPilot annotation is optional. It gives editor completion; the framework ignores it.
Plug
You can add dashboard to a plug's __init__ to receive the same client.
class SerialRegistry:
def __init__(self, dashboard, mode="api"):
self._client = dashboarddashboard cannot be set from with: (or its old name config:).
A scope: station plug keeps the client across runs. When the station logs in again (tofupilot login --token issues a new key), the next run respawns held plugs with the new key.
Identity
The procedure acts as the identity the CLI is logged in with, whether or not the run uploads. Uploading is a separate choice: --upload decides where the run's results go, not what the procedure can read.
| Run | Identity |
|---|---|
Station daemon, kiosk, tofupilot run --deployment | The station |
tofupilot run ., with or without --upload, on a development machine | The user login when there is one, the station login otherwise |
Studio runs and plug debugging, tofupilot plug | The user login when there is one, the station login otherwise |
| Any of the above on a machine with no login | None |
With no login, a phase or plug asking for dashboard fails with DashboardUnavailable and asks you to run tofupilot login. In setup: that failure skips every later phase, so log in before running a procedure that reads the dashboard.
The procedure can call what the identity can call. A station creates and reads units, parts, revisions and batches, updates units, and reads its own linked procedures and runs. A user has the permissions of their role, see access roles. Permissions are managed in the dashboard, not in the procedure.
Station only
You can stop a procedure that relies on the station identity (created_by_station filters, stations.get_current()) before it runs as a user.
def setup(dashboard, phase):
me = dashboard.identity.whoami()
if me.type != "station":
phase.fail(f"This procedure acts as a station; the run uploads as {me.user.email}") identity.whoami() (GET /v2/whoami) answers for both kinds of key: type is station or user, and the matching object is set. stations.get_current() and users.get_current() refuse the other kind of key.
Environment Variables
Every process the framework starts for the procedure has these variables: phase workers, plug processes, shell phases, and anything they spawn.
| Variable | Value |
|---|---|
TOFUPILOT_API_KEY | The API key of the CLI's login |
TOFUPILOT_URL | The instance base URL, without /api (the value tofupilot login --url takes) |
TOFUPILOT_CA_CERT | Path of the private CA bundle, only on an instance that uses one |
You can read them to build your own client or call the API from a shell phase.
import os
from tofupilot.v2 import TofuPilot
client = TofuPilot(server_url=os.environ["TOFUPILOT_URL"] + "/api") # key read from the environmentmain:
- name: Who am I
executable:
command: >
curl -sS -H "Authorization: Bearer $TOFUPILOT_API_KEY"
${TOFUPILOT_CA_CERT:+--cacert $TOFUPILOT_CA_CERT}
"$TOFUPILOT_URL/api/v2/whoami"A procedure never inherits a key from the machine. The CLI's login replaces any TOFUPILOT_API_KEY set on the station, and nothing is set when the CLI is not logged in.
The key is the identity's own. Do not write it to a file or a log; the framework sets it in the environment on every run.
Private CA
Nothing to configure in the procedure. The dashboard client trusts the instance's private CA on top of the default bundle, so the procedure's other HTTPS calls are unaffected.
Code that builds its own client loads TOFUPILOT_CA_CERT into its own SSL context.
Errors
Calls are not queued. A call made while the server is unreachable raises the SDK's transport error, and a server error raises a TofuPilotError with its status.
import httpx
from tofupilot.v2.errors import TofuPilotError
def create_unit(dashboard, phase, unit):
try:
dashboard.units.create(serial_number=unit.serial_number, part_number=unit.part_number)
except httpx.TransportError:
phase.retry() # the server is unreachable: try again later
except TofuPilotError as e:
if e.status_code >= 500 or e.status_code == 429:
phase.retry()
raise # a 4xx is a bug in the procedure, not an outageA phase that needs a write to succeed must fail or retry. A phase that continues after a failed units.create leaves the run upload to create the unit later, without the metadata the phase meant to set.
Run uploads are unaffected: the station queues them and retries on its own.
Requirements
- CLI 1.9.3 or later. CLI 1.9.0 to 1.9.2 required a
dashboard:block inprocedure.yaml, which is now refused at load. Before CLI 2.10.1, a run without--uploadhad no identity anddashboardfailed. - The
tofupilotpackage in the procedure's dependencies (pyproject.toml), 2.22 or later foridentity.whoami()andusers.get_current(). A phase or plug asking fordashboardwithout it fails with that message.
How is this guide?
Plugs
Create persistent resources like equipment drivers and database connections for your test phases to access. Reuse plugs across procedures.
Sequences
Write a group of phases once in a sequence file and call it from several TofuPilot procedures with uses, with inputs, plug bindings and its own outcome.