# An iOS simulator API: create, install, tap, screenshot over REST

Create an iPhone or iPad simulator with one POST, upload your simulator build, read the screen, tap and save a screenshot: every call, a tested curl script, the same in JavaScript, and park and start to keep your app between sessions.

By [Mustafa Yenler](https://mobilebox.dev/about?via=md#mustafa) [LinkedIn](https://www.linkedin.com/in/mustafa-yenler) Updated 23 November 2026

Guides6 min read

In this article

Mobilebox’s REST API gives you an iOS simulator in one call: `POST /v1/phones` with `{"platform":"ios"}` returns a ready iPhone, or an iPad with `"model":"ipad"`, and the same API installs your simulator build, reads the screen, taps, types and returns screenshots, at $0.03 a minute. The base URL is https://mobilebox.dev/v1 with your API key as a bearer token, so any language and any OS can call it, no Mac needed.

It is the API behind the [iOS simulator MCP server](https://mobilebox.dev/ios-simulator-mcp?via=md) and the same one Mobilebox’s cloud Android phones use, so code written for one runs on the other. Field by field, it is in the [API reference](https://mobilebox.dev/docs/reference?via=md#devices).

## The calls

| Step | Request | Answer |
| --- | --- | --- |
| Create | POST /v1/phones?wait=ready with {"platform":"ios"}, optional "model":"ipad", name, idle_timeout, max_duration | The phone: id, platform: "ios", model, status, per_minute_usd, and a notice |
| Install | POST /v1/phones/{id}/apps with the .zip as the body (Content-Type: application/zip), or JSON {"url": "…"} | 201 {package, version_code, version_name}: the bundle id and versions from your Info.plist; the app opens |
| Read | GET /v1/phones/{id}/observe, or ?format=text | The app in front and every element: ref, type, text, state, center in screenshot pixels |
| Act | POST /v1/phones/{id}/actions with 1 to 20 actions | Each action’s result and the new screen |
| Screenshot | GET /v1/phones/{id}/screenshot | image/png |
| Logs | GET /v1/phones/{id}/apps/{bundle_id}/logs | Your app’s log lines |
| Watch | POST /v1/phones/{id}/view | {url, expires_at}: a live view of the screen |
| Delete | DELETE /v1/phones/{id} | 204; billing stops |

Actions on a simulator: `tap` on a target (`{"text": "Sign in"}`, `{"ref": 4}` or `{"x": 540, "y": 1200}`), `type` with optional `submit`, `swipe`, `scroll`, `key` with `enter`, and `home`. Send `Authorization: Bearer $MOBILESANDBOX_API_KEY` on every call.

## A complete script in curl

Set `APP_ZIP` to your simulator build and `TAP_TEXT` to a button on its first screen. The script creates an iPhone simulator, installs the app, prints the screen, taps, saves a screenshot and deletes the simulator, also when a step fails.

```
#!/usr/bin/env bash
# Create an iOS simulator, install a simulator build, read the screen, tap, screenshot, delete.
set -euo pipefail
MSB=${MOBILESANDBOX_URL:-https://mobilebox.dev}
AUTH="Authorization: Bearer ${MOBILESANDBOX_API_KEY:?set MOBILESANDBOX_API_KEY}"
APP_ZIP=${APP_ZIP:?set APP_ZIP to a .zip of your simulator .app}
TAP_TEXT=${TAP_TEXT:-Continue}
api() { curl -sS --fail-with-body -H "$AUTH" "$@"; }

PHONE=$(api -X POST "$MSB/v1/phones?wait=ready" -H 'Content-Type: application/json' \
  -d '{"platform":"ios","name":"api-check","idle_timeout":120,"max_duration":600}')
ID=$(jq -r .id <<<"$PHONE")
trap 'api -X DELETE "$MSB/v1/phones/$ID" && echo "deleted $ID"' EXIT
[ "$(jq -r .status <<<"$PHONE")" = ready ] || { echo "not ready: $PHONE" >&2; exit 1; }

api -X POST "$MSB/v1/phones/$ID/apps" -H 'Content-Type: application/zip' --data-binary @"$APP_ZIP"
echo
api "$MSB/v1/phones/$ID/observe?format=text"

api -X POST "$MSB/v1/phones/$ID/actions" -H 'Content-Type: application/json' \
  -d "{\"actions\":[{\"type\":\"tap\",\"target\":{\"text\":\"$TAP_TEXT\"}}]}" \
  | jq -e -r 'if all(.results[]; .ok) then .screen.text else (.results | tostring | halt_error) end'

api "$MSB/v1/phones/$ID/screenshot" -o "${SCREENSHOT:-screen.png}" && echo "saved ${SCREENSHOT:-screen.png}"
```

A tap that misses fails the job with the error’s `code` and `next`, for example `element_not_found` when no element has that text, and the trap still deletes the simulator. Our test suite runs this script against a local test server on every change; it checks the request shapes and the cleanup, not a real simulator.

## The same in JavaScript

Node 20 or newer, no dependencies. Save it as `ios-check.mjs` and run `node ios-check.mjs`.

```
const base = process.env.MOBILESANDBOX_URL ?? 'https://mobilebox.dev'
const { MOBILESANDBOX_API_KEY: key, APP_ZIP, TAP_TEXT = 'Continue', SCREENSHOT = 'screen.png' } = process.env
if (!key || !APP_ZIP) throw new Error('Set MOBILESANDBOX_API_KEY and APP_ZIP')
const { readFile, writeFile } = await import('node:fs/promises')

async function call(path, method = 'GET', body, type = 'application/json') {
  const res = await fetch(base + path, {
    method,
    headers: { Authorization: `Bearer ${key}`, ...(body === undefined ? {} : { 'Content-Type': type }) },
    ...(body === undefined ? {} : { body: type === 'application/json' ? JSON.stringify(body) : body }),
  })
  if (!res.ok) throw new Error(`${method} ${path} → ${res.status} ${await res.text()}`)
  return res.headers.get('content-type')?.includes('json') ? res.json() : res
}

const phone = await call('/v1/phones?wait=ready', 'POST', { platform: 'ios', name: 'api-check' })
try {
  if (phone.status !== 'ready') throw new Error(`not ready: ${phone.status}`)
  const app = await call(`/v1/phones/${phone.id}/apps`, 'POST', await readFile(APP_ZIP), 'application/zip')
  console.log(`installed ${app.package} ${app.version_name}`)
  const { results, screen } = await call(`/v1/phones/${phone.id}/actions`, 'POST', {
    actions: [{ type: 'tap', target: { text: TAP_TEXT } }],
  })
  if (!results.every((r) => r.ok)) throw new Error(JSON.stringify(results))
  console.log(screen.text)
  const png = await call(`/v1/phones/${phone.id}/screenshot`)
  await writeFile(SCREENSHOT, Buffer.from(await png.arrayBuffer()))
} finally {
  await call(`/v1/phones/${phone.id}`, 'DELETE')
  console.log(`deleted ${phone.id}`)
}
```

## Make the build

Build for an iOS Simulator and zip the `.app` with its folder at the top:

```
xcodebuild -scheme YourApp -configuration Debug -destination 'generic/platform=iOS Simulator' \
  -derivedDataPath build CODE_SIGNING_ALLOWED=NO
cd build/Build/Products/Debug-iphonesimulator && ditto -c -k --keepParent YourApp.app YourApp.zip
```

That step needs Xcode; a macOS CI runner does it if you have no Mac, as [running an iOS simulator without a Mac](https://mobilebox.dev/blog/ios-simulator-without-a-mac?via=md) shows. App Store and device (.ipa) builds don’t run on simulators: the install answers 400 `invalid_app` and says how to make the simulator build.

## Keep the app between sessions

A simulator doesn’t have to start empty each run. `POST /v1/phones/{id}/park` shuts it down, free, and `POST /v1/phones/{id}/start` brings it back with the apps you installed, so the next run skips the upload and install. Where the simulator’s saved state can be restored, the apps come back with their data, keychain and sign-ins, as on a [parked Android phone](https://mobilebox.dev/blog/park-resume-android?via=md). Where it can’t, the apps are reinstalled fresh. The started phone’s `restored` field says which, so your agent knows whether to sign in again:

```
POST /v1/phones/{id}/apps   → {"package":"cloud.run.examples.screenshot","version_code":1,"version_name":"1.0"}
POST /v1/phones/{id}/park   → the simulator parks; billing stops
POST /v1/phones/{id}/start  → restored: {"apps":["cloud.run.examples.screenshot"],"data":true,
                               "note":"Restored from the saved state: cloud.run.examples.screenshot, with their data and sign-ins."}
GET  /v1/phones/{id}/apps   → {"data":[{"package":"cloud.run.examples.screenshot","version_code":1}]}
```

That is our production run on November 22, 2026. `"data": false` means a fresh reinstall: the app is there, its data and sign-ins aren’t. A build that could not be reinstalled is listed in `failed`. Permissions, location and simulator settings aren’t part of the saved state, so set them again after a start. A start right after a park can take about a minute, because the state is still being saved; a later start doesn’t wait. Uninstalling an app drops it from what start brings back, and deleting the phone deletes the saved state and the kept builds. Over MCP these are `park_phone` and `start_phone`.

## Retries and cost

Send an `Idempotency-Key` header with the create, and a retry after a lost response returns the same simulator instead of a second one. The rest is billed per second at $0.03 a minute with a one-minute minimum, so the script above costs $0.03 for a run under a minute. A run with no credit answers 402 `insufficient_credits` with a top-up link for your user. Need the agent to drive it instead of your code: [test an iOS app with Claude Code, Cursor or Codex](https://mobilebox.dev/blog/ios-app-testing-claude-code-cursor-codex?via=md).

[Mustafa Yenler](https://mobilebox.dev/about?via=md#mustafa) is the founder of fifteenA and builds Mobilebox, from Berlin and San Francisco. [LinkedIn](https://www.linkedin.com/in/mustafa-yenler)

## Try it in your agent in 60 seconds

Paste this into Claude Code, Cursor, Codex or any agent that can read a web page. It asks for your email, gets its own key at once and adds the phone tools; the 6-digit code from your inbox keeps the workspace.

```
Set up Mobilebox for me: read https://mobilebox.dev/setup.md?via=ios-simulator-api and follow it.
```

[What your agent reads](https://mobilebox.dev/setup.md?via=ios-simulator-api)

In this article

[All articles](https://mobilebox.dev/blog?via=md)

## Next question

- [Can my agent use an iPhone?](https://mobilebox.dev/ios?via=next-iphone)
