> ## Documentation index
> Fetch the complete index at: https://maritime.sh/llms.txt
> Setup procedure for AI agents (install, sign in, deploy, verify): https://maritime.sh/agents.md
> This page as HTML: https://maritime.sh/docs/metal

# Metal phones

Computers on demand

Metal phones are real Android phones in a Maritime rack, dedicated to your account. Connect your local adb to
every phone with one command:

```bash
maritime phones connect
```

Each phone then shows in `adb devices` as `127.0.0.1:600N`, where N is the phone's number. This needs the
[Maritime CLI](https://maritime.sh/docs/cli) 2.8.0 or later, signed in or with `MARITIME_API_KEY` set.

To run Appium tests, you need no adb and no local Appium. Point your tests at the [hosted Appium hub](#appium).

## Your phones

- Each phone is named `<model> · NN`, such as `Pixel 7 · 03`. NN is the phone's number on your account.
- A phone keeps its name, number and id for as long as it is assigned to you.
- Phones never sleep. A phone is always ready, unless it is offline.
- Each phone is an [Android phone](https://maritime.sh/docs/phones) computer. Your agent uses the same screenshot,
  action, file, viewer and takeover API.
- The Maritime team sets up Metal. Tell us how many phones you need and the email of your Maritime account. The
  phones then show on the Android phones page of the dashboard.

## When to use it

- Apps that detect emulators or need Google Play services.
- Apps that only ship ARM code, at full speed.
- A fixed set of devices your agents keep, with their apps and sign-ins, from one task to the next.

For short tasks on a clean phone, a virtual [Android phone](https://maritime.sh/docs/phones) is cheaper and starts
empty every time.

## Hosted Appium

Maritime runs Appium next to your phones. Point your Appium client at the hub and sign in with your API key:

```text
https://api.maritime.sh/wd/hub
```

The hub accepts HTTP Basic auth with any user name and your API key as the password. Most clients take the
credentials in the URL:

```text
https://maritime:$MARITIME_API_KEY@api.maritime.sh/wd/hub
```

A `Bearer` token in the `Authorization` header also works. `maritime phones appium` prints the hub URL, how to
sign in and example capabilities. The `appium`, `apps` and `sessions` commands need the CLI 2.9.0 or later.

### Capabilities

Send standard Appium capabilities. Put Maritime's own options in `maritime:options`:

```json
{
  "platformName": "Android",
  "appium:automationName": "UiAutomator2",
  "appium:app": "maritime://app_8Kq2wXr5Tn3Lp0Vb7Yc1",
  "maritime:options": {
    "phone": 3,
    "name": "Checkout flow",
    "build": "412"
  }
}
```

- `phone`: the phone's number on your account, or its computer id.
- `name` and `build`: labels for the session. They show in the Sessions tab and in `maritime phones sessions`.
- The flat forms `maritime:phone`, `maritime:name` and `maritime:build` also work.

The hub sets `platformName` to `Android`, the device id and the driver ports. `appium:automationName` defaults
to `UiAutomator2`.

```python
import os

from appium import webdriver
from appium.options.android import UiAutomator2Options

options = UiAutomator2Options()
options.app = "maritime://app_8Kq2wXr5Tn3Lp0Vb7Yc1"
options.set_capability("maritime:options", {"name": "Checkout flow", "build": "412"})

hub = f"https://maritime:{os.environ['MARITIME_API_KEY']}@api.maritime.sh/wd/hub"
driver = webdriver.Remote(hub, options=options)
try:
    print(driver.current_activity)
finally:
    driver.quit()
```

### How a phone is chosen

- With `phone`, the session runs on that phone.
- Without it, the hub picks a phone whose model contains `appium:deviceName`, ignoring case. Without
  `appium:deviceName`, it picks any phone.
- The hub picks only your phones that are online, ready and not in another Appium session. A phone runs one
  session at a time.
- When every phone it can pick is busy, the hub waits up to 60 seconds. Then it answers `session not created`
  with "All N phones are busy".

### Timeouts

`appium:newCommandTimeout` is how long a session waits for the next command before it ends. The default is 120
seconds. The hub accepts 10 to 600 seconds and moves a value outside that range to the nearest end.

### Refused capabilities

The hub refuses a session with `capability_not_allowed` when it sets a capability that reaches the host's disk
or other devices:

- `appium:chromedriverExecutable`
- `appium:chromedriverExecutableDir`
- `appium:chromedriverChromeMappingFile`
- `appium:keystorePath`
- `appium:adbPort`
- `appium:remoteAdbHost`

`appium:app` and each `appium:otherApps` entry must be a `maritime://` app or an http or https URL. A local
path is refused. The hub removes `bstack:options`, `sauce:options`, `lt:options` and `LT:Options`, so you can
leave them in while you switch.

## Apps

Upload an APK once and use it in any session. An APK can be up to 1 GiB. Uploading the same file again returns the
same app.

```bash
maritime apps upload app.apk      # prints the app id and its maritime:// URL
maritime apps list
maritime apps delete app_8Kq2wXr5Tn3Lp0Vb7Yc1
```

With curl:

```bash
curl -u maritime:$MARITIME_API_KEY -F file=@app.apk https://api.maritime.sh/api/v1/apps
```

```json
{
  "id": "app_8Kq2wXr5Tn3Lp0Vb7Yc1",
  "name": "app.apk",
  "sha256": "c8ee23651112c45efd025ac692ba7b78e7364293aaf1615a7d222bbef341b732",
  "sizeBytes": 48211337,
  "appUrl": "maritime://app_8Kq2wXr5Tn3Lp0Vb7Yc1",
  "createdAt": "2026-11-23T18:04:11Z"
}
```

Use the app in a session with its `appUrl`:

```json
"appium:app": "maritime://app_8Kq2wXr5Tn3Lp0Vb7Yc1"
```

Each phone keeps a copy of the app, so the next session does not download it again.

To install an app without Appium, use `maritime phones install`. It installs on every Metal phone unless you name
phones. It grants the app's runtime permissions unless you add `--no-grant`.

```bash
maritime phones install app.apk                        # every Metal phone
maritime phones install app_8Kq2wXr5Tn3Lp0Vb7Yc1 3 4    # phones 3 and 4
maritime phones install app.apk --no-grant             # keep runtime permissions off
```

The API is `POST /api/v1/apps`, `GET /api/v1/apps`, `GET /api/v1/apps/{id}` and `DELETE /api/v1/apps/{id}`.
`POST /api/v1/computers/{id}/apps` with `{"appId": "app_...", "grantPermissions": true}` installs an app on one
phone.

## Session recordings

Every session on the hosted hub records three files:

- A video of the screen.
- The phone's logcat.
- A command log, with one JSON line per command: the time, method, path, status and milliseconds. Request and
  response bodies are not logged.

The files upload when the session ends. Maritime keeps them for 30 days. A recording problem never fails your
session.

The **Sessions** tab on the Android phones page of the dashboard lists your sessions. Open one to watch the video
and read the logs. From the CLI:

```bash
maritime phones sessions            # recent sessions on every phone
maritime phones sessions 3          # recent sessions on phone 3
maritime phones session <id> --download ./artifacts
```

From the API, `GET /api/v1/appium/sessions` lists sessions, newest first. `GET /api/v1/appium/sessions/{id}` adds
`videoUrl`, `logcatUrl` and `commandsUrl`. Each link works for 1 hour.

## Run in CI

Your CI job needs only your API key. In GitHub, add it as a repository secret named `MARITIME_API_KEY` in
**Settings > Secrets and variables > Actions**. This job uploads the app and runs the tests on the hosted hub:

```yaml
name: Android tests
on: push

jobs:
  appium:
    runs-on: ubuntu-latest
    env:
      MARITIME_API_KEY: ${{ secrets.MARITIME_API_KEY }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: pip install Appium-Python-Client pytest
      - name: Upload the app
        run: |
          APP_URL=$(curl -s -u maritime:$MARITIME_API_KEY -F file=@app.apk https://api.maritime.sh/api/v1/apps | jq -r .appUrl)
          echo "MARITIME_APP=$APP_URL" >> "$GITHUB_ENV"
      - name: Run the tests
        run: pytest tests
        env:
          BUILD: ${{ github.run_number }}
```

`tests/test_app.py` opens one session per test, named after the test:

```python
import os

import pytest
from appium import webdriver
from appium.options.android import UiAutomator2Options

HUB = f"https://maritime:{os.environ['MARITIME_API_KEY']}@api.maritime.sh/wd/hub"


@pytest.fixture
def driver(request):
    options = UiAutomator2Options()
    options.app = os.environ["MARITIME_APP"]
    options.set_capability("maritime:options", {
        "name": request.node.name,
        "build": os.environ.get("BUILD", "local"),
    })
    session = webdriver.Remote(HUB, options=options)
    yield session
    session.quit()


def test_app_starts(driver):
    assert driver.current_activity
```

To use adb in CI instead, connect the phones in the background, run your tools against the serials, and disconnect
at the end:

```yaml
    steps:
      - uses: actions/checkout@v4
      - run: npm install -g maritime-cli
      - run: maritime phones connect --background
      - run: adb -s 127.0.0.1:6003 shell getprop ro.product.model
      - if: always()
        run: maritime phones disconnect
```

## Moving from BrowserStack, Sauce Labs or LambdaTest

Most suites move by changing the hub URL, the key and the app id:

1. Upload your app with `maritime apps upload app.apk`.
2. Change the hub URL to `https://api.maritime.sh/wd/hub` and sign in with your Maritime API key.
3. Set `appium:app` to the app's `maritime://` URL. The hub refuses `bs://`, `sauce-storage:` and `lt://` ids
   and tells you to upload the app.
4. Move the session name and build into `maritime:options`.

| Setting | BrowserStack | Sauce Labs | LambdaTest | Maritime |
| --- | --- | --- | --- | --- |
| Hub URL | `https://hub-cloud.browserstack.com/wd/hub` | `https://ondemand.us-west-1.saucelabs.com/wd/hub` | `https://mobile-hub.lambdatest.com/wd/hub` | `https://api.maritime.sh/wd/hub` |
| Auth | User name and access key | User name and access key | User name and access key | Any user name and your Maritime API key |
| App upload | `bs://<id>` | `storage:<id>` or `sauce-storage:<file>` | `lt://<id>` | `maritime://app_...` from `maritime apps upload` |
| Device | `bstack:options.deviceName` | `appium:deviceName` | `lt:options.deviceName` | `maritime:options.phone`, or `appium:deviceName` to match a model |
| Session name | `bstack:options.sessionName` | `sauce:options.name` | `lt:options.name` | `maritime:options.name` |
| Build | `bstack:options.buildName` | `sauce:options.build` | `lt:options.build` | `maritime:options.build` |
| Video and logs | Dashboard | Dashboard | Dashboard | Sessions tab, or `maritime phones session <id> --download <dir>` |

## Connect adb

Every phone has a stable local port: 6000 plus its number. Phone 3 is always `127.0.0.1:6003`, so scripts and
test configs keep working from one day to the next.

```bash
maritime phones                     # list your phones with their adb serials
maritime phones connect             # connect every phone
maritime phones connect 3           # connect phone 3 only
maritime phones connect --background
maritime phones disconnect          # stop a background connection
maritime phones scrcpy 3            # open phone 3's screen in scrcpy
```

`maritime phones connect` runs `adb connect` for each phone. It stays in the foreground until you press Ctrl+C.
Add `--background` to detach it, and run `maritime phones disconnect` to stop it. `maritime phones scrcpy` needs
scrcpy installed on your machine.

adb gives full control of the phone, including settings and a factory reset. A phone you reset stays assigned to
you, but setting it up again is up to you.

## Local Appium and Maestro

To run your own Appium server or Maestro, run `maritime phones connect` first. Then use the phone's serial, `127.0.0.1:600N`, as the device id.

```json
{
  "platformName": "Android",
  "appium:automationName": "UiAutomator2",
  "appium:udid": "127.0.0.1:6003"
}
```

```bash
maestro --device 127.0.0.1:6003 test flow.yaml
```

## Drive them from the API

- Actions, screenshots, `ui_tree`, app control and the MCP tools work as on any
  [Android phone](https://maritime.sh/docs/phones#actions).
- The screen is set to 720 x 1280 while a computer uses the phone, with the density scaled to match. Screenshot
  pixels and tap coordinates match one to one, as on a virtual phone.
- The Android phones page of the dashboard shows every phone's live screen. **Take over** lets a person use a phone
  by touch, with Back, Home and Recents keys. **Hand back** returns it to the agent.

## Device info in the API

Every computer in `GET /api/v1/computers` has a `device` field. On a Metal phone it holds the phone's number,
model, Android version, battery, temperature, whether it is online, when it was last read, and its local adb port.
On a virtual computer it is `null`.

```json
{
  "id": "3f6c2a9e-7b41-4d8a-9c55-1e2f0b7d4a63",
  "os": "android",
  "name": "Pixel 7 · 03",
  "status": "ready",
  "device": {
    "number": 3,
    "model": "Pixel 7",
    "androidVersion": "14",
    "batteryPercent": 81,
    "temperatureC": 31.5,
    "charging": true,
    "online": true,
    "checkedAt": "2026-11-20T21:00:00Z",
    "adbPort": 6003
  }
}
```

List your Metal phones by number:

```bash
curl -s https://api.maritime.sh/api/v1/computers \
  -H "Authorization: Bearer $MARITIME_API_KEY" \
  | jq -r '.computers[] | select(.device != null) | "\(.device.number)  \(.id)  \(.name)"'
```

## Team access

The phones are on the account of the organization's owner. To share them, the owner invites teammates in
[Settings > Organization](https://maritime.sh/settings/organization) with **Invite member**. Everyone in the
organization sees the phones on the Android phones page and can use them. Admins can also make their own API keys.
A key works only as far as its maker's role, and it stops when they leave.

## Health

We monitor every phone. We get an alert when a phone goes offline or runs hot, and we fix it. While a phone is
offline, its `device.online` is `false` and the dashboard shows it as offline. You do not need to report it.

## Billing

Metal is not metered on usage. Your agreement with the Maritime team sets the price.

## Move or wipe a phone

You cannot delete a Metal phone. The dashboard has no Kill for it, and `DELETE /api/v1/computers/{id}` answers
409. To move a phone to another account, or to wipe it, ask the Maritime team.

## Related

- [Android phones](https://maritime.sh/docs/phones)
- [Linux desktops and the Computers API](https://maritime.sh/docs/computers)
- [CLI](https://maritime.sh/docs/cli)
