Client

getStorage()

api.getStorage() → Promise<Storage | null>

The account's default storage, as four plain fields. Where a save with no target goes.

GET /api/storage/defaultfreea plain object
Using Python?

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

Returns

{
  id: "…",
  label: "Object Storage",
  type: "object",
  tier: "free"
}
{
    "id": "…",
    "label": "Object Storage",
    "type": "object",
    "tier": "free",
}
idstring

What you pass as storageId to anything that writes.

labelstring

The display name. Yours to change, not to match on.

typestring

What kind of storage it is — see below. This is the field to branch on.

tierstring

The storage's tier.

Every account is created with its own object storage, and that is the one carrying the default flag — so this call normally answers with somewhere you can actually write.

type, and why it decides everything

typeWhat it isFiles live
objectAn object storage: bytes under keys.On the account
databaseA connected database, read and written through run().On the account
filesystemA computer. Its files are on that machine.On the machine, under ~/.iagenify/files
phoneA registered phone. Its files are in its own browser.In that browser
browserA browser store.In that browser
A computer and a phone keep no bytes on the account

Saving to one through the server is refused with storage_is_local — not because it failed, but because those files only exist on the device. Read and write them from the device, through the SDK running there or through a bridge.

The three things you may actually want

await api.getStorage();                      // the default, as plain fields

const target = await api.storage.get();      // the default, with run() and files on it
const one = await api.storage.get({ id });   // a particular storage
const all = await api.storage.list();        // every storage on the account
api.get_storage()                      # the default, as plain fields

target = api.storage.get()             # the default, with run() and files on it
one = api.storage.get(id=storage_id)   # a particular storage
every = api.storage.list()             # every storage on the account
This is not a ConnectedStorage

Four fields, no methods. Use this call to display which storage is the default; use api.storage.get() when you intend to do something with it.

api.storage.get() reads the same route and hands back a ConnectedStorage — the object that carries run(), and files when the storage is a machine.

What the default flag actually decides

  • A save with no storageId goes there.
  • It is a property of the account, not of your client: changing machines does not change it.
  • Exactly one active storage carries it. Delete that storage and the flag is handed to another — it is never left nowhere.
  • It does not decide where an agent works. An agent works on the device it was given, and that is a separate choice.

When it is null

null means no active storage carries the flag. Since deleting the holder hands the flag on, a null is unusual enough to look at rather than retry.

const target = await api.getStorage();

if (!target) {
  const all = await api.storage.list();
  throw new Error(`no default storage; ${all.length} storage(s) on the account`);
}

if (target.type === "filesystem" || target.type === "phone") {
  // Saving here through the server will be refused: this device keeps its own files.
}
target = api.get_storage()

if target is None:
    every = api.storage.list()
    raise RuntimeError(f"no default storage; {len(every)} storage(s) on the account")

if target["type"] in ("filesystem", "phone"):
    pass  # Saving here through the server will be refused: this device keeps its own files.

Writing to a named storage instead

Relying on the default is fine for one storage and fragile for several: the flag can move. When a process must always write to the same place, resolve it by label once and keep the id.

const all = await api.storage.list();
const archive = all.find((s) => s.label === "Archive" && s.type === "object");
if (!archive) throw new Error("the Archive storage is not connected");

// Keep archive.id in configuration, and pass it explicitly from then on.
archive = next((s for s in api.storage.list() if s.label == "Archive" and s.type == "object"), None)
if archive is None:
    raise RuntimeError("the Archive storage is not connected")

# Keep archive.id in configuration, and pass it explicitly from then on.