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

# Tunnel 1 — the private API

> Tunnel 1 is how your own machines and API agents talk to the phone: directly, over your tailnet, with nothing exposed to the public internet.

Tunnel 1 is how your own machines and API agents talk to the phone: directly, over your tailnet, with nothing exposed to the public internet.

## One address only

The bridge listens on **one address only** — the phone's Tailscale address, port **8765**. It does not listen on your Wi-Fi LAN address, and it does not listen on any public interface. If the Tailscale VPN is down, the bridge is not reachable at all; that is a security property, not a bug. Tailscale's WireGuard encryption protects the traffic, and a named token is the second factor on top of it.

Anything that can make an HTTP request can use Tunnel 1: a tool-calling agent, an MCP client, a script, or you with `curl` from another machine on the tailnet.

## Step 1 — Be on the tailnet

The calling machine must be signed into the **same Tailscale account** (the same tailnet) as the phone, with Tailscale running. That is the whole network requirement: no port forwarding, no router changes, no public address for the phone. From the calling machine you should be able to reach the phone's Tailscale address — the app's Status screen shows it in the bridge status table, in the Tunnel 1 row.

The address looks like `100.x.y.z` (Tailscale's address range). You can also use the phone's MagicDNS name if your tailnet has MagicDNS enabled. The examples on this page use `<phone-tailnet-ip>` as a placeholder — substitute the address from your app.

## Step 2 — Create a token

Every caller gets its **own named token** — one for your laptop script, one for each agent. That way the Activity screen can show who did what, and revoking one caller never locks out the others.

1. Open **Tokens** in the app.
2. On the **Tunnel 1 — Private** card, name the token and create it. Names are 3–64 characters: lowercase letters, numbers, dashes, and underscores (for example `my-laptop` or `agent-1`).
3. The app shows the token's **connect block** — once. Copy or share it now; the value is never displayed again. If you lose it, create a new token (or rotate) and revoke the lost one.

The first token is special: on a fresh install the app generates one automatically during Get Connected, and holds it for you until you tap "Done — I've shared it." After that, the same shown-once rule applies.

Tokens are stored on the phone encrypted (AES-256-GCM, with the key in the Android Keystore), are compared in constant time, and never appear in the app's logs. On a purchased copy, tokens persist across restarts; on a free copy they are session-only — see the [pricing summary](https://docs.leverine.com/bunnybridge/index.md#price-in-one-paragraph). You can rename a token or move it between tunnels later from the same screen, without changing its value; see [Security](https://docs.leverine.com/bunnybridge/security.md) for the full token lifecycle, including rotation grace and the revoke undo window.

## Step 3 — The connect block, field by field

The connect block is the entire integration in one paste. It looks like this (placeholder values):

```
BunnyBridge — Tunnel 1 (private)
url: http://<phone-tailnet-ip>:8765
token: YOUR_TOKEN
agent guide: https://docs.leverine.com/BunnyBridge/for-agents.html

Send the token as the X-Token header on every call.
Start with GET /health, then GET /status, then POST /run.
```

| Field | What it is |
| - | - |
| Heading | Which tunnel this block is for. Tunnel 1 blocks are for the private API; Tunnel 2 blocks look different and carry a public address instead. |
| `url` | The base address of the bridge on the tailnet. Every endpoint path is appended to this. |
| `token` | The token's value — a password for this one caller. Treat it like one: never commit it to a repository, paste it into logs, or print it in full. |
| Agent guide | A link to the [For Agents](https://docs.leverine.com/bunnybridge/for-agents.md) page, so an AI handed this block can teach itself the rules. |
| Instructions | The short version of the protocol: the header to send, and the order to call endpoints in. |

Give the block to your agent as-is, or use the fields yourself from a script. On purchased copies, the reveal sheet and Get Connected offer a **Share** button that sends the whole block through the Android share sheet — email it to the computer where your AI runs. Sharing exists only where the block is already visible: a stored token's value can never be re-displayed, so it can never be re-shared later.

## Step 4 — A worked example

### 1. Liveness — no token needed

```
curl -s http://<phone-tailnet-ip>:8765/health
```

```
{"ok": true, "version": "0.4.10", "uptime_s": 823,
 "listening": true, "tailnet_address": "<phone-tailnet-ip>",
 "active_runs": 0}
```

An empty reply or a refused connection means nothing is listening — the bridge is stopped or Tailscale is down. That is deliberately different from an authentication failure, which always answers.

### 2. Full health — with your token

```
curl -s -H "X-Token: YOUR_TOKEN" \
  http://<phone-tailnet-ip>:8765/health
```

With a valid token, `/health` returns the full self-diagnosis: the same three lists the Status screen shows (`permissions_missing`, `software_missing`, `state_missing`), a `ready` flag, and a summary of Tunnel 2's state. Each item says whether the agent can resolve it or only you can, with the instruction for you when it's yours. Check this before your first real command, and whenever something fails.

### 3. Status

```
curl -s -H "X-Token: YOUR_TOKEN" \
  http://<phone-tailnet-ip>:8765/status
```

```
{"version": "0.4.10", "uptime_s": 823,
 "tailnet_address": "<phone-tailnet-ip>",
 "token_name": "agent-1",
 "tokens": ["first-token", "agent-1"],
 "hosts": []}
```

Status shows names only — token names and host names, never values or keys.

### 4. Run a command

```
curl -s -X POST -H "X-Token: YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"cmd": "echo door1-test-ok; date"}' \
  http://<phone-tailnet-ip>:8765/run
```

```
{"stdout": "door1-test-ok\nSat Dec  5 17:01:39 EST 2026\n",
 "stderr": "", "code": 0, "id": "run-1",
 "duration_ms": 214, "truncated": false}
```

The command runs on the phone, inside the app's sandbox. The response carries the output, the exit `code`, a run `id`, how long it took, and whether the output was truncated. Up to **4 commands** may run at once on Tunnel 1; there is no per-minute call cap on this tunnel. An optional `timeout` (seconds) bounds a single command. The `host` field will run the command on a configured SSH host instead — that capability arrives with the jump-host phase (see the note below).

### 5. The event log

```
curl -s -H "X-Token: YOUR_TOKEN" \
  "http://<phone-tailnet-ip>:8765/log?session=current"
```

`GET /log` returns the app's event log as plain text — app starts, diagnosis runs, permission answers, token operations (names only), updater events, errors with stack traces. `?tail=N` fetches the last N entries; `?session=current` fetches everything since the user last tapped "Start test session" in the Log screen — the slice to ask for first when something misbehaved. **The log exists on Tunnel 1 only**: there is no log endpoint on the public tunnel, by design.

**(Roadmap) SSH jump hosts.** A later phase adds the Hosts screen (name, address, user, key — keys generated in-app or imported) and lets `/run` execute on those machines through the phone, with `/status` listing host names. Until then, `/health` reports "no hosts configured" as an informational state item, and a command sent with a `host` completes with a clear refusal rather than running anywhere.

## Errors on Tunnel 1

| What you see | What it means |
| - | - |
| Empty reply / connection refused | Nothing is listening: bridge stopped, or Tailscale down on either end. Open the app; the Status screen says which. Don't retry in a loop. |
| `403` | Token wrong, revoked, or rotated past its grace window. Ask for a fresh connect block. |
| Command times out | The command ran past its timeout. Say so plainly; never blindly resend a command whose outcome is unknown. |

The full endpoint-by-endpoint reference — request and response shapes, every error — is in the [API Reference](https://docs.leverine.com/bunnybridge/api-reference.md). If you are handing this tunnel to an AI, the [For Agents](https://docs.leverine.com/bunnybridge/for-agents.md) page is the etiquette that goes with it.

***

*Source: Leverine/Leverine-BunnyBridge\@902c77c — `docs/site/BunnyBridge/door1.html`.*


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.