# Telefone

Canonical URL: https://developers.iagenify.com/pt/sdk/ref/providers/phone/
Language: pt

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

Telefone o tablet del visitante, registrat dal applicazion che detiene la chiave — il telefono non lo vee. I suoi files live in suo browser.

Status: type: phone · registered for it · files via a bridge

Un telefono non può registrarse, e che è l'intero design: la chiave sta sul tuo server, il telefono non tiene ninguna cosa se non un identificatore al azar, e il server chiama `device()` in suo nome.

## Registrare un {#register}

```javascript
// 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
```

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `deviceId` | string | obrigatório | `dev_` seguiu da 16 a 64 lettere e cifres. Tutto o resto è rifiutato. |
| `name` | string |  | Il nome display, 80 caracteres a macis. Derivè del agente utente quando ausente. |
| `userAgent` | string |  | Agent d'usuari del telefono, 400 caracteres al massimo. Usato per nome e decrivi-lo. |

## L'identificant è a te da conservare {#deviceid}

Generalo una volta nella pagina, tèlo in quel browser, e envialo con ogni chiamata. Il medesimo identificator sempre risolve al medesimo storage, dicindo `device()` in ogni page lo lo load è normal e crea nulla di nuovo.

```javascript
// In the page
const id = localStorage.getItem("device")
  || `dev_${crypto.randomUUID().replace(/-/g, "")}`;
localStorage.setItem("device", id);
```

> **Un identificatât che non corrisponde a forma è negat**
>
> invalid_device_id ritorna su qualsiasi cosa che non è dev_ plus 16 a 64 lettere e digits. A UUID con i suoi guilleti lasciati in è la causa usual.

## I suoi files sono in suo browser {#files}

Nulla dei dati di un telefono è sul conto, e nulla di esso è sul servidor. `phone.files` quindi lança `storage_is_phone` — un renie que dice dove i files realmente sono, invece di fingir non c'è.

Per raggiunger-li, la pagina che li tiene fa il lavoro: un agent dato `files` come un ponte fluisce ogni operazion aquella pagina, la pagina lo runde su su propri storage, e la risposta retorna. It is the sujett of [bridges · files](/pt/sdk/agent/bridges/files).

```javascript
const agent = api.agents.create({
  runtime: "local",
  machine: phone,
  files: phoneBridge(),            // yours: it talks to the page
  model: "gemini-3.5-flash",
});
```

## Un telefono non è mai il predefinit {#never-default}

Registrare uno non move il stoccaj predefinit del cont, qualunque altra cosa è là. Un salvament senza target non avrebbe nòdù per ande.

## Un telefono per petizione {#appname}

`appName`, dato al cliente quando lo costruisci, separa dispositivi registratis da diverse applicazioni del mesmo compte. Il mesmo telefono utilizzato da due de tes applicazioni è dos storages, che è o que impede uno de listare dels altri.

## Due registrazioni simultanee sono un stoccaggio {#race}

Pages duplo-fogo — un refresco, un framework que monta due vezes. Concurrente chiamas con o mesmo identificator se assente sobre un solo storage e ambos lo recupera, por lo que no es necesario guarda de la tua.

## Erros {#errors}

| Código | Status | Quando |
| --- | --- | --- |
| invalid_device_id | 400 | `deviceId` non corrisponde `dev_` + 16–64 letras e cifres. |
| storage_is_phone | 400 | `phone.files` a fost rtlltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltl |

- [Pontes · files](/pt/sdk/agent/bridges/files): Operazione de files in esecuzione sul dispositivo que le detiene.
- [device()](/pt/sdk/ref/storage/device): Il grida in se.
- [Computador](/pt/sdk/ref/providers/computer): Dispositivo cui i files sono su un disco.

```python
# 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"
```

```python
# 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"]
```

```python
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",
)
```
