> ## Documentation Index
> Fetch the complete documentation index at: https://servo.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Sign in to the CLI and authenticate robot applications.

## CLI login

`servo login` opens a browser for interactive authentication on development machines, storing credentials
locally in `~/.config/servo/token.json`.

Set the control-plane URL supplied by your Servo administrator, then sign in:

```bash theme={null}
export SERVO_BASE_URL="https://<your-servo-control-plane>"
servo login
servo whoami
```

Login state is stored on the current computer. Pass `--base-url` to select a different control
plane for one command.

For **headless robot computers** (such as remote IPCs accessed over SSH), do not run `servo login` on
the robot. Instead, create an API key on your development computer and export `SERVO_API_KEY` on the robot.

## Robot applications and automation

Python applications and noninteractive CLI commands use an organization API key:

```bash theme={null}
servo key create --label yam-cell-01
export SERVO_API_KEY="sk_servo_..."
```

Servo displays the secret once. Store it in the robot computer's secret manager. The key
authorizes the application; the robot's stable name and `rob_*` ID identify the physical rig. A
robot computer with `SERVO_API_KEY` set can run `servo robot setup` without `servo login`.

List and revoke keys with:

```bash theme={null}
servo key list --active
servo key revoke <key-id>
```

## Python

```python theme={null}
import os

import servo

sv = servo.Servo(
    base_url=os.environ["SERVO_BASE_URL"],
    api_key=os.environ["SERVO_API_KEY"],
)
```

Missing or invalid credentials return `401`. A valid credential without permission for an
operation returns `403`.
