Providers

Phone

api.storage.device({ deviceId, name, userAgent }) → Promise<ConnectedStorage>

A visitor's phone or tablet, registered by the application that holds the key — the phone never sees it. Its files live in its own browser.

type: phoneregistered for itfiles via a bridge
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

A phone cannot register itself, and that is the whole design: the key stays on your server, the phone keeps nothing but a random identifier, and your server calls device() on its behalf.

Registering one

// On your server — this is where the key is
const phone = await api.storage.device({
  deviceId,                              // kept in the phone's own browser
  name: "Zayd's iPhone",                 // optional
  userAgent,                             // optional, used to name it
});

// phone.type === "phone"   phone.provider === "browser"   phone.deviceId === deviceId
# On your server — this is where the key is
phone = api.storage.device(
    device_id=device_id,           # kept in the phone's own browser
    name="Zayd's iPhone",          # optional
    user_agent=user_agent,         # optional, used to name it
)

# phone.type == "phone"   phone.provider == "browser"
deviceIdstringrequired

dev_ followed by 16 to 64 letters and digits. Anything else is refused.

namestring

The display name, 80 characters at most. Derived from the user agent when absent.

userAgentstring

The phone's user agent, 400 characters at most. Used to name and describe it.

The identifier is yours to keep

Generate it once in the page, keep it in that browser, and send it with every call. The same identifier always resolves to the same storage, so calling device() on every page load is normal and creates nothing new.

// In the page
const id = localStorage.getItem("device")
  || `dev_${crypto.randomUUID().replace(/-/g, "")}`;
localStorage.setItem("device", id);
# In the page (JavaScript) — the browser keeps its own id:
#   const id = localStorage.getItem("device")
#     || "dev_" + crypto.randomUUID().replace(/-/g, "");
#   localStorage.setItem("device", id);
#
# Python receives that id from the page, e.g. in a request header.
device_id = request.headers["X-Device-Id"]
An identifier that does not match the shape is refused

invalid_device_id comes back on anything that is not dev_ plus 16 to 64 letters and digits. A UUID with its dashes left in is the usual cause.

Its files are in its browser

Nothing of a phone's data is on the account, and nothing of it is on your server either. phone.files therefore throws storage_is_phone — a refusal that says where the files actually are, rather than pretending there are none.

To reach them, the page that holds them does the work: an agent given files as a bridge streams each operation to that page, the page runs it on its own storage, and the answer travels back. That is the subject of bridges · files.

const agent = api.agents.create({
  runtime: "local",
  machine: phone,
  files: phoneBridge(),            // yours: it talks to the page
  model: "gemini-3.5-flash",
});
agent = api.agents.create(
    runtime="local",
    machine=phone,
    files=PhoneBridge(),   # yours: an object with list/read/write/mkdir/move/remove that talks to the page
    model="gemini-3.5-flash",
)

A phone is never the default

Registering one does not move the account's default storage, whatever else is there. A save with no target would have nowhere to go.

One phone per application

appName, given to the client when you construct it, separates devices registered by different applications of the same account. The same phone used by two of your applications is two storages, which is what keeps one from listing the other's.

Two simultaneous registrations are one storage

Pages double-fire — a refresh, a framework that mounts twice. Concurrent calls with the same identifier settle on a single storage and both get it back, so no guard of yours is needed.

Errors

CodeStatusWhen
invalid_device_id400deviceId does not match dev_ + 16–64 letters and digits.
storage_is_phone400phone.files was reached from outside that browser.