Concepts

Sessions

The key is exchanged once for a JWT and a refresh token. After that the key stays where you put it, and the client renews the session on its own.

exchanged oncerefreshed automatically
Using Python?

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

The order of preference

Before each call the client picks the cheapest thing that will work.

StateWhat happens
A cached JWT that has not expiredused as-is — no network
Expired, but a refresh token is cachedrenewed, then used
Refresh fails, or nothing is cachedthe key is exchanged
No key and no cached sessionthe constructor refused long before this

Expiry is read from the token itself, not guessed from a timer, so a process that was asleep for a day behaves the same as one that was busy.

What is cached

{ jwt, refreshToken, sessionId, storageId }
# Stored in ~/.iagenify/session (or your session_path / storage)
{"jwt": ..., "refresh_token": ..., "session_id": ..., "storage_id": ...}

storageId is how a machine keeps the same identity across restarts: it is sent back on the next exchange so the same machine is recognised rather than registered twice.

await api.session();
// { id, storageId } — or null when nothing has been exchanged yet
api.session()
# {"id", "storageId"} — or None when nothing has been exchanged yet

Concurrent first calls

Fire ten calls at once on a cold client and there is one exchange, not ten. The deduplication is keyed by the key and the appName, and it holds across client instances in the same process — which is what makes a double render harmless.

// One exchange, ten calls
await Promise.all([
  api.getUser(),
  api.catalogue(),
  api.storage.list(),
  api.keys.list(),
  /* … */
]);
# One exchange, ten calls: the first call exchanges the key, the others reuse it
from concurrent.futures import ThreadPoolExecutor

with ThreadPoolExecutor() as pool:
    user, prices, storages, keys = pool.map(lambda call: call(), [
        api.get_user,
        api.catalogue,
        api.storage.list,
        api.keys.list,
    ])

Ending a session

await api.auth.logout();            // this session
await api.auth.revokeSession(id);   // another one, by id
api.auth.logout()                    # this session
api.auth.revoke_session(session_id)  # another one, by id
Logging out is not the same as revoking a key

A session ends; the key still works and the next call exchanges it again. To stop a key entirely, revoke the key.