Mobile infrastructure for AI agent products: a phone per customer, sign-in handoff and safe failures.
The six layers, and what each takes
| Layer | What you need | On Phonebox |
|---|---|---|
| A phone per customer | A device that keeps apps, files and sign-ins between tasks | Persistent phones, tagged with your customer ID, found again by metadata |
| A readable screen | The screen as structured text, not only pixels | Numbered elements with text, description, ID and position, plus a screenshot |
| Sign-in handoff | A way for the customer to enter codes and passwords themselves | Live view links, from 1 minute to 24 hours, no account needed |
| Safe failures | Errors that say what happened and what to do next; no blind retries | Every error carries retryable and next; writes are never retried |
| Tenant isolation | One customer's agent can't touch another's phone | Separate phones; API keys limited to one customer's phones |
| Cost control | Idle customers cost nothing | Park after each task; idle timeout as a backstop; per-session costs |
Find or create a customer's phone
Give each customer one phone, created the first time they need it and reused after that. The idempotency key makes a retried create return the same phone instead of billing a second one:
import { Phonebox } from "phonebox";
const pb = new Phonebox(); // reads PHONEBOX_API_KEY
// The customer's phone: found by your own ID, created once, started when parked.
export async function phoneFor(customer: string) {
let [phone] = (await pb.phones.list({ metadata: { customer } })).data;
phone ??= await pb.phones.create({
name: `customer-${customer}`,
metadata: { customer },
idempotencyKey: `customer-${customer}-phone-1`, // a retried create returns the same phone
});
if (phone.status === "parking") await phone.waitUntil("parked");
if (phone.status === "creating" || phone.status === "starting") await phone.waitUntil("ready");
if (phone.status !== "ready") await phone.start(); // resumes a parked phone
return phone;
}Run one task at a time on a phone, for example through a queue per customer: Phonebox doesn't lock phones, and two agents on one phone act on screens they didn't read. The multi-tenant guide covers keys for customers whose phone was deleted. For the whole API in curl and how it compares with other device APIs, see cloud Android phone APIs.
Let the customer sign in themselves
Your agent drives the sign-in until it reaches a step only the account owner should take, such as a code sent to their own phone. It then sends them a live view link, waits for the next screen, and carries on:
# A link the customer opens to sign in themselves, valid for 15 minutes
curl https://phonebox.dev/v1/phones/$PHONE_ID/live \
-H "Authorization: Bearer $PHONEBOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"expires_in": 900}'The account stays signed in while the phone is parked, so the customer does this once. Phonebox never stores what the agent types; activity records it as [redacted]. Anyone with a live link controls the phone until it expires, so send it only to that customer.
Failures your agent can act on
A model that hits an error needs to know whether to retry and what to do instead. Every Phonebox error has the same shape:
{
"error": {
"type": "conflict_error",
"code": "phone_not_running",
"message": "The phone isn't running.",
"retryable": false,
"next": "POST /v1/phones/ph_7kx2m6q4v3ta/start",
"request_id": "req_e2f5g3h6j4k7",
"details": { "status": "parked" }
}
}Phonebox never retries a write, because a tap or a payment might already have happened. When a write isn't confirmed, the error is action_outcome_unknown: the agent reads the screen before it does anything else.
What it costs per customer
| Phone use a day | Per customer per month |
|---|---|
| 2 minutes | $3.60 |
| 10 minutes | $18 |
| 30 minutes | $54 |
| Signed up, never used | $0 |
Starter holds 10 phones and runs 5 at once; Pro holds 50 and runs 20; email team@phonebox.dev for more. GET /v1/phones/{id}/sessions returns each session's cost, so you can bill or cap customers from your own data.
More ways to use a cloud phone
Questions
What infrastructure do I need for an AI agent that uses mobile apps?
A persistent phone per end user, a way for the model to read the screen as text, a human handoff for sign-ins, errors the agent can act on without blind retries, isolation between customers, and costs that stop when a phone is idle. Phonebox provides these through one API, with cloud Android phones at $0.06 a minute that cost nothing while parked.
How do I give each customer of my AI product their own phone?
Create one Phonebox phone per customer with POST /v1/phones, tag it with your customer ID as metadata, and find it again with the metadata filter. Use an idempotency key so a retried create returns the same phone. Park it after each task: it keeps the customer's apps and sign-ins and costs nothing.
How do I let my AI agent hand off a phone to a human for a sign-in?
Create a live view link with POST /v1/phones/{id}/live and send it to the account owner. They open it in a browser, enter their code or password themselves, and your agent waits for the next screen and continues. The phone stays signed in while parked.
Is there an API for cloud Android phones?
Yes. Phonebox has a REST API, a TypeScript SDK, a CLI and a hosted MCP server for cloud Android phones: create, start and park phones, read the screen, tap and type, install APKs, record the screen and create live view links.
Get started with Phonebox. New accounts start with a free 7-day trial, card required.
The Phonebox team