# Cloud devices (managed cloud, outside the EU)

Attach Android emulators and iOS simulators to a running miniVM so your agent can install, drive and screenshot your app. Managed cloud only, off by default, run outside the EU.

Cloud devices are Android emulators and iOS simulators that you attach to a running miniVM. Your
agent installs your app on them, taps, types, reads the screen and takes screenshots, from inside
the miniVM.

## What a device is

Every cloud device is a virtual device in the cloud, not a physical handset:

| Kind                                                 | What it is                                                                       |
| ---------------------------------------------------- | -------------------------------------------------------------------------------- |
| `android_phone`, `android_tablet`                    | An Android emulator of a phone or a tablet                                       |
| `ios_simulator`, `ipad`, `apple_watch`, `iphone_duo` | A simulator of an iPhone, an iPad, an Apple Watch (watchOS) or a foldable iPhone |

Physical devices are not offered yet. An iOS simulator runs simulator builds of your app only.

> **Warning:** **Cloud devices run outside the EU.** They run at a third-party provider established outside the
> EU, subject to non-EU law. Your app, its screens and its screenshots leave the EU, and so do your
> source code and build logs when you use [app builds](https://onshore.sh/docs/app-builds). The provider is listed on the [sub-processors page](https://onshore.sh/docs/legal/subprocessors). Everything else about your
> miniVMs stays in the EU.

## Managed cloud only

Cloud devices exist only on the onshore.sh managed cloud. A self-hosted deployment does not offer
them, and every `ons device` command there prints:

```text
Devices are available on onshore.sh managed cloud only; this deployment does not offer them
```

and exits with code 1. With `--json`, the error carries the reason `devices_not_offered`. The
dashboard of a self-hosted deployment shows no cloud device setting.

They are not available on miniVMs of a [Hybrid](https://onshore.sh/docs/guides/hybrid) pool either.

## Turn them on

Cloud devices are off by default. Only an owner of the organization can turn them on:

1. Open the dashboard, then **Settings › Cloud devices**.
2. Read the consent text the dashboard shows. Its current version (2026-11-30) reads: "Cloud
   devices and app builds run at a third-party provider subject to non-EU law: your app, its
   source code, its build logs, its screens and its screenshots are sent to and stored by that
   provider, outside onshore.sh's EU perimeter. Copies of your source code kept to speed up
   builds are deleted at most 30 days after your last build."
3. Tick the box and select **Turn on cloud devices**.

An organization that turned cloud devices on under an earlier version keeps its devices. Its
[app builds](https://onshore.sh/docs/app-builds) are refused until an owner accepts the current version.

The dashboard then shows who turned them on and when. We keep that consent (who, when, which
version of the text) for the life of your account.

Members who are not owners cannot see or change the setting. Until your organization has a payment
method, cloud devices cannot be turned on: add one first.

Turning them off releases every device of the organization at once. Running miniVMs lose the
`device` command within seconds, or at their next resume.

## Use them from inside a miniVM

Once cloud devices are on, every miniVM of the organization on the managed pool has the `device`
command and a `minisandbox-devices` skill for your coding agent: running miniVMs get them within
seconds, paused ones when they resume. The miniVM holds no credential for them: onshore.sh adds
it on the way out.

```bash
device add android_phone --wait
device install app-release.apk
device tap --text "Sign in"
device screenshot -o screen.png
device remove <device-id>
```

`<device-id>` is the id `device add` printed (`dev_…`). Run `device --help` for every command
(`list`, `wait`, `launch`, `ui`, `type`, `swipe`, `press`, `open-url`, `adb`, `keep` and more). Every
command takes `--json`.

### adb on Android devices

`device adb` gives adb access to an Android device through a local tunnel. adb is not in the base
templates. Install it in a miniVM whose template allows the `ubuntu` egress preset (write
`presets: [ubuntu]` under `egress` in your recipe):

```bash
sudo apt-get update && sudo apt-get install -y adb
```

To have it in every miniVM, add the same install to the `setup` of your template's
[`minisandbox.yaml`](https://onshore.sh/docs/reference/minisandbox-yaml) with `ubuntu` in its `egress` presets. Then:

```bash
device adb <device-id> -- shell getprop ro.build.version.release
device adb <device-id>
```

`<device-id>` is the id `device add` printed; leave it out when the miniVM has a single device.
The first command runs adb with the arguments after `--`; without adb installed, it fails at once
and says so. The second one opens the tunnel and keeps it open until you press Ctrl-C: with adb
installed, it connects adb to the device; without, it prints an `adb connect 127.0.0.1:<port>`
line for a tool that has adb.

## Build your app from source

Inside the miniVM, `device build ios` or `device build android` builds your app from its source on
a cloud builder and installs it on the device. See [App builds](https://onshore.sh/docs/app-builds): they are off by
default and turned on per organization.

## Use them from your machine

`ons device` attaches, lists, keeps and removes the devices of a miniVM:

```bash
ons device kinds
ons device add <minivm-id> android_phone --wait
ons device ls <minivm-id>
ons device keep <minivm-id> <device-id> --for 45m
ons device rm <minivm-id> <device-id>
```

`<minivm-id>` is the miniVM's id, as `ons create` printed it. `<device-id>` is the id `ons device
add` printed. `ons device kinds` lists the device kinds and their OS versions; `ons device kinds --json` also
gives each kind's price per minute in credits (`creditsPerMinute`). Every command takes `--json`.

### When `ons device add --wait` fails

`--wait` returns once the device is ready. It stops early when the device is released before
that:

| `reason` (in `--json`) | What happened                                                                         | What to do                                                  |
| ---------------------- | ------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| `device_unavailable`   | The device did not start in time. `retryAfter` gives the seconds to wait. Not billed. | Run the same `ons device add` again after that delay.       |
| `device_lost`          | The device stopped answering and was released.                                        | Add a new one.                                              |
| `device_released`      | The device was released for another reason, given in `detail`.                        | Add it again, or pick another kind with `ons device kinds`. |

These exit with code `1`. When `--timeout` (default `10m`) passes first, `ons device add` exits
with code `124` and says how to see or release the device, which may still be starting.

## Limits

| Limit                             | Value                                                 |
| --------------------------------- | ----------------------------------------------------- |
| Devices per miniVM                | 3                                                     |
| Idle release                      | 5 minutes without any command to the device           |
| `device keep` / `ons device keep` | Extends the idle delay by at most 60 minutes per call |
| Devices at once per organization  | 3 (0 until a payment method is saved)                 |
| Devices added per organization    | 20 per hour                                           |
| Device minutes per organization   | 300 per day, 3,000 per month (UTC)                    |

To raise an organization limit, write to <support@onshore.sh>.

## Billing

- **Per started minute, from boot to release.** A device is billed from the moment it starts
  booting until you release it. Billing stops at your release request, not when the provider
  finishes shutting the device down. A started minute counts in full.
- **Failed starts are free.** A device that never becomes ready (not ready within 90 seconds) is
  released and costs nothing, boot time included; the add answers `device_unavailable` with a
  `Retry-After` header.
- **Price.** A fixed price per minute in credits: 4 for Android, 7 for iOS, including a large iOS
  device. A device keeps the price it was added at. `ons device kinds --json` gives the
  price in credits of each kind (`creditsPerMinute`). See [Pricing](https://onshore.sh/docs/account/pricing#cloud-devices).
- **From your credits.** Device minutes are drawn from your credits like the rest of your usage.
  Adding a device needs at least 10 minutes of that device's price in your balance.
- **At 0 credits.** When your balance reaches 0 credits, every device of the organization is released within
  a minute.
- **Minute limits.** The daily and monthly device minute limits refuse new devices; they do not
  release the ones already attached.

See [Billing](https://onshore.sh/docs/account/billing) for credits and top-ups.

## When a device is released

A device is released, and its billing stops, when:

- you remove it, or an owner turns cloud devices off (`removed`);
- its miniVM pauses (`paused`) or is killed (`killed`). This includes [auto-pause when idle](https://onshore.sh/docs/guides/lifecycle#auto-pause-when-idle): a miniVM that pauses after its idle delay releases its devices too;
- nothing used it for 5 minutes (`idle`);
- the organization's credit reaches 0 credits (`limit`);
- the device fails at the provider (`provider_error`);
- the device's session at the provider drops while you use it (`lost`). Billing stops at the
  moment of the loss.

A paused miniVM gets no device back when it resumes: add a new one.

### Events

Four events tell you what happened to a device. Your [webhooks](https://onshore.sh/docs/reference/api#webhooks) and the
API's [event stream](https://onshore.sh/docs/reference/api#events) get them when they name them: in a webhook's `events`,
or in the stream's `types`:

| Event                     | When                                                                         |
| ------------------------- | ---------------------------------------------------------------------------- |
| `devices.device_ready`    | The device is ready to use                                                   |
| `devices.device_failed`   | The device could not start                                                   |
| `devices.device_lost`     | The device's session dropped while in use; it is released with reason `lost` |
| `devices.device_released` | The device was released; `reason` is one of the reasons above                |

Their data holds ids and enums only: `device_id`, `kind`, `platform` and, for a failure or a
release, `reason`. `devices.device_lost` also carries the miniVM's id, `sandboxID`.

## Refusals

When a device cannot be added, the API answers with its usual error body, a `reason`, sometimes a
`detail`, and a `Retry-After` header (seconds) when waiting helps. `ons device` and `device` print
the same reason.

| HTTP | `reason`                | `detail`                                                        | What to do                                                                                                        |
| ---- | ----------------------- | --------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| 400  | `invalid_request`       | `kind`, `os`                                                    | Pick a kind and OS version from `ons device kinds`                                                                |
| 400  | `too_many_devices`      |                                                                 | A miniVM has at most 3 devices: remove one                                                                        |
| 402  | `insufficient_credits`  |                                                                 | Add credits: you need 10 minutes of the device's price                                                            |
| 403  | `devices_disabled`      | `not_enabled`                                                   | An owner turns cloud devices on in the dashboard                                                                  |
| 403  | `devices_disabled`      | `payment_method`                                                | An owner adds a payment method on **Billing**                                                                     |
| 403  | `devices_disabled`      | `hybrid`                                                        | Use a miniVM of the managed pool                                                                                  |
| 409  | `feature_not_live`      |                                                                 | This device kind is not available yet                                                                             |
| 409  | `sandbox_not_running`   |                                                                 | Resume the miniVM, then add the device                                                                            |
| 429  | `device_quota_exceeded` | `concurrent`, `attach_rate`, `daily_minutes`, `monthly_minutes` | Retry after `Retry-After`, or remove a device                                                                     |
| 503  | `device_capacity`       |                                                                 | No device is free right now: retry after 60 seconds                                                               |
| 503  | `device_unavailable`    |                                                                 | The device service is busy, or the device was not ready within 90 seconds (not billed): retry after `Retry-After` |
| 502  | `device_provider_error` |                                                                 | The device could not be started: retry, or pick another kind or OS version                                        |
| 404  | `minivm_not_found`      |                                                                 | No miniVM with this id in your organization: check the id with `ons ls`                                           |
| 404  | `device_not_found`      |                                                                 | The device is not one of this miniVM's                                                                            |
| 404  | `route_not_found`       |                                                                 | No such devices route: check the command or the URL                                                               |
| 503  | `devices_unavailable`   |                                                                 | Cloud devices are unavailable right now: retry after `Retry-After`                                                |

## Your data

- **Nothing stored by onshore.sh.** Screens, screenshots, UI trees, device logs and your app pass
  through onshore.sh on their way between your miniVM and the device. We never write them to disk
  or logs.
- **At the provider.** Your app is installed only on the device, and the device's screens and logs
  exist there while it runs. They are gone when the device is released and its instance deleted.
- **What we keep.** The device usage lines (device id, kind, minutes, price) are billing records,
  kept like your other billing lines. The consent to turn cloud devices on is kept for the life of
  your account. See [Data handling](https://onshore.sh/docs/security/data-handling).
- **App builds.** Source code and build logs: see [App builds](https://onshore.sh/docs/app-builds#your-data).

Markdown version: https://onshore.sh/docs/devices.md
