A computer registers itself: the SDK runs there, exchanges the key, and the machine becomes a storage. A phone cannot — the SDK is not on it and must not be, because the key would be. So the page sends an identifier to your server, and your server calls this.
Parameters
deviceIdstringrequiredA random identifier the page keeps. Missing → the SDK throws.
namestringThe display name. Derived from the user agent when absent.
userAgentstringThe phone's user agent, used for that name.
The same deviceId is the same storage
Calling it again with an identifier already seen returns the existing storage rather than making another. So the page can call it on every load without piling up registrations — and two simultaneous calls still produce one.
// In the page: an identifier that survives reloads
let deviceId = localStorage.getItem("device");
if (!deviceId) {
deviceId = `dev_${crypto.randomUUID()}`;
localStorage.setItem("device", deviceId);
}
// On your server, where the key is
export async function registerPhone(deviceId, userAgent) {
const phone = await api.storage.device({ deviceId, userAgent });
return phone.id;
}# In the page (JavaScript): an identifier that survives reloads
# localStorage.getItem("device") || `dev_${crypto.randomUUID()}`
# On your Python server, where the key is
def register_phone(device_id, user_agent):
phone = api.storage.device(device_id=device_id, user_agent=user_agent)
return phone.idA value built from the user agent, the screen or an account is the same for many people — and whoever sends it gets that storage. Random, kept in the browser, is what makes it one device.
Returns
phone.id;
phone.type; // "phone"
phone.provider; // "browser"
phone.deviceId; // the identifier you passedphone.id
phone.type # "phone"
phone.provider # "browser"Its files are not on the account
Saving to it through the server is refused with storage_is_local. Reading and writing them happens in the page, which is where they are — your server relays the request and the page answers.
That is also what makes a phone a sensible place for an agent to work: nothing is uploaded to be read. See the files bridge.
appName separates two apps on one phone
A storage is identified by the account, the device and the appName the client was built with. Two apps on one phone are two storages — which is usually what you want, since their files have nothing to do with each other.
const api = new IaGenify({ apiKey, appName: "field-notes" });
await api.storage.device({ deviceId }); // this app's storage on this phoneapi = IaGenify(api_key=api_key, app_name="field-notes")
api.storage.device(device_id=device_id) # this app's storage on this phoneErrors
| Code | Status | When |
|---|---|---|
| — (thrown locally) | — | No deviceId passed. |
| unauthorized | 401 | No valid session or key — the call is your server's, not the phone's. |