CLOUSD
Open account
Developers

Cloud phone API: control Android phones from code

What a cloud phone API should let you do, and how it looks in practice: create a phone, install a build, act on the screen, read it back and hand over whole tasks, with curl and Python examples you can run.

A cloud phone is only as useful to a developer as its API. A live screen in the browser is fine for a manual check, but a pipeline, a script or an agent needs to create a phone, put an app on it, act, read the result and throw the phone away, all without a person in the loop.

This guide goes through what a cloud phone API should cover and shows each part with Clousd's REST API, in curl and Python. The same calls are behind the dashboard, the Python SDK and the MCP server.

What a cloud phone API should cover

Five jobs, in the order a script needs them:

  1. Lifecycle. Create, start, stop, reset and delete phones, and know when each is ready.
  2. Apps. Get a build onto the phone without a person dragging a file.
  3. Actions. Tap, type, swipe, press keys, open an app or a link.
  4. Reading the screen. A screenshot, and the elements on it as text, so code can check what happened.
  5. Whole tasks. Hand over a goal and get an answer, for flows that are not worth scripting step by step.

Around those, the practical details decide whether the API survives contact with production: retries that do not create a second phone, long operations you can poll, keys you can limit to some phones, and errors that say what to fix.

Authentication

Every request carries a key in the Authorization header:

export CLOUSD_KEY=cl_live_your_key
curl https://api.clousd.com/v1/devices -H "Authorization: Bearer $CLOUSD_KEY"

Keys are created in the dashboard and shown once. A key can cover all your phones or only the ones you choose, and can be allowed to control phones or only to see them.

Lifecycle: create, wait, stop, reset

Ask which Android versions you can create, then create a phone:

curl https://api.clousd.com/v1/android -H "Authorization: Bearer $CLOUSD_KEY"

curl -X POST https://api.clousd.com/v1/devices \
  -H "Authorization: Bearer $CLOUSD_KEY" \
  -H "Idempotency-Key: nightly-2026-11-25-a15" \
  -d '{"android":"15"}'

The answer is a 202 with the phone's name and the state starting. It becomes running in about a minute. The Idempotency-Key header matters: if the request times out and you send it again with the same key within 10 minutes, you get the same phone, not a second one.

The rest of the lifecycle is one call each:

POST   /v1/devices/{name}/start
POST   /v1/devices/{name}/stop
POST   /v1/devices/{name}/reset      wipe apps and data, keep the Android version
DELETE /v1/devices/{name}            to Trash for 14 days

Start, stop and restart answer with a job you can follow at GET /v1/jobs/{id}. Stop keeps everything on the phone and ends the billing. Reset gives you the same phone as new, which is what a test run wants between cases.

Apps: upload once, install anywhere

Upload a build to your private storage, then install it by id on any of your phones:

curl -X POST https://api.clousd.com/v1/apps \
  -H "Authorization: Bearer $CLOUSD_KEY" -F file=@app-release.apk

curl -X POST https://api.clousd.com/v1/apps/{id}/install \
  -H "Authorization: Bearer $CLOUSD_KEY" -H "Content-Type: application/json" \
  -d '{"devices": ["Phone #1", "Phone #2"]}'

Files up to 300 MB are accepted. Each one is checked before it is stored: it has to be a valid Android app, and native code has to include 64-bit ARM. For a one-off, adb install over the ADB relay does the same job; see ADB over the internet.

Actions and reading the screen

One step at a time:

POST /v1/devices/{name}/action  {"op":"open_app","package":"com.example.shop"}
POST /v1/devices/{name}/action  {"op":"tap_text","text":"Sign in"}
GET  /v1/devices/{name}/screenshot?w=540

The action endpoint covers open_app, close_app, url, tap, swipe, text, key and scroll, plus helpers that work on what is written on the screen: find_text, tap_text, wait_text and screen_text. Tapping by text survives a layout change that would break a tap by coordinates.

In Python the same flow reads like a test:

from clousd import Clousd

c = Clousd()                                   # key from CLOUSD_API_KEY
phone = c.device("c3f9a41d2")
phone.open_app("com.example.shop")
phone.tap_text("Sign in")
phone.type("qa@example.com")
phone.key("enter")
phone.wait_text("Orders", timeout=30)
png = phone.screenshot(width=540)

Install the SDK with pip install clousd. Long operations return a job and wait by default.

For an agent that decides its own steps there is a pair built for that loop: observe returns a fresh screenshot with every element numbered and the elements as text with their positions, and act performs one step and refuses to act on a stale screen.

Whole tasks

Some flows are not worth scripting. For those, send the goal in plain words:

POST /v1/runs
{
  "task": "Open the app, sign in with the saved login and tell me how many orders are on the Orders page",
  "device": "c3f9a41d2",
  "credentials": [{"package": "com.example.shop", "name": "work"}],
  "options": {"output_schema": {"type": "object", "properties": {"orders": {"type": "integer"}}}}
}

Clousd's agent does the steps on the phone and the run ends with an answer and, with a schema, structured_output in that shape. Saved logins are typed on the phone and never reach the model or the API response. Every step is kept with a screenshot, so a failed run can be replayed. Give devices instead of device and the same task runs on up to 32 phones at once.

Runs can also start by themselves: a schedule takes a task, phones, a time and days.

The details that matter in production

  • Rate limits and retries. The API answers 429 when you go too fast; the Python client waits and retries by itself.
  • Jobs. Anything that takes time returns a job id instead of holding the connection open.
  • Events. Runs stream their status, steps and answer as server-sent events, and can be resumed after a dropped connection.
  • Webhooks. For systems that would rather be told than poll.
  • An MCP server. The same phones for AI assistants, at one address. The guide to the Android MCP server covers it.

The full reference is in the documentation.

What it costs to automate

The API has no price of its own. You pay for the phones: $0.004 a minute while a phone runs, never more than $0.80 a phone a day, and nothing while it is stopped. A script that creates a phone, runs for ten minutes and stops it spends $0.04. The first 30 minutes are free with no card; creating API keys needs a funded account, from $10.

Two limits to plan around: Clousd phones are cloud devices, not handsets, so there is no physical camera or sensor and no device certification is claimed; and a phone has no number for calls or SMS.

Keep reading

All guides

Ready to launch
your first cloud phone?

Try free for 30 minutes

No card needed