Returns
{
ok: true,
keys: [
{
id: "…",
name: "ci",
prefix: "ia_…",
scopes: ["*"],
lastUsedAt: "2026-10-07T09:12:44.102Z",
expiresAt: null,
isActive: true,
createdAt: "2026-09-30T18:02:11.000Z"
}
]
}{
"ok": True,
"keys": [
{
"id": "…",
"name": "ci",
"prefix": "ia_…",
"scopes": ["*"],
"lastUsedAt": "2026-10-07T09:12:44.102Z",
"expiresAt": None,
"isActive": True,
"createdAt": "2026-09-30T18:02:11.000Z",
}
],
}idstringWhat revoke() takes. It appears here and nowhere else.
namestringThe name given when the key was created, in your account. Not unique — two keys may share one.
prefixstringThe short identifier. This is how you match a stored key to a row here.
scopesstring[]The label recorded with the key. ["*"] when none was given.
lastUsedAtstring|nullUpdated whenever the key is used. null means it never has been.
expiresAtstring|nullAn expiry, when the key carries one. null otherwise.
isActivebooleanRevoking sets this to false.
createdAtstringWhen it was made. Newest first.
Dates are ISO strings, so Date.parse reads them and a plain string comparison sorts them. Revoked keys are not returned: the lookup is scoped to the account's active keys.
Which row is the key I am holding
Never by comparing the key itself — the list has no secret to compare against. Store the prefix next to the key when you deploy it, and matching is exact and harmless.
const { keys } = await api.keys.list();
const mine = keys.find((k) => k.prefix === process.env.IAGENIFY_KEY_PREFIX);
if (!mine) {
// The key this process holds is not an active key on the account any more.
throw new Error("this deployment is running on a revoked or unknown key");
}import os
keys = api.keys.list()["keys"]
mine = next((k for k in keys if k["prefix"] == os.environ["IAGENIFY_KEY_PREFIX"]), None)
if mine is None:
# The key this process holds is not an active key on the account any more.
raise RuntimeError("this deployment is running on a revoked or unknown key")The audit this gives you
lastUsedAt is the only field here that tells you something you did not already know. Two questions are worth asking of it.
What is not being used
const { keys } = await api.keys.list();
const month = Date.now() - 30 * 24 * 60 * 60 * 1000;
const idle = keys.filter((k) => !k.lastUsedAt || Date.parse(k.lastUsedAt) < month);
for (const k of idle) {
console.warn(`${k.name} (${k.prefix}) · last used ${k.lastUsedAt ?? "never"}`);
}from datetime import datetime, timedelta, timezone
keys = api.keys.list()["keys"]
month = datetime.now(timezone.utc) - timedelta(days=30)
def when(value): return datetime.fromisoformat(value.replace("Z", "+00:00"))
idle = [k for k in keys if not k.get("lastUsedAt") or when(k["lastUsedAt"]) < month]
for k in idle:
print(f"{k['name']} ({k['prefix']}) · last used {k.get('lastUsedAt') or 'never'}")A key nothing uses is a key that can be revoked, and every one you retire is one less thing to leak. A key that has never been used is usually a rotation that was created and never deployed.
What is being used when it should not be
// A key belonging to a deployment you have retired should go quiet.
// If it does not, something still holds it.
const retired = keys.find((k) => k.name === "old-batch-runner");
if (retired?.lastUsedAt && Date.parse(retired.lastUsedAt) > Date.parse(retiredOn)) {
// Something is still calling with it. Revoke it and find out what breaks.
}# A key belonging to a deployment you have retired should go quiet.
# If it does not, something still holds it.
retired = next((k for k in keys if k["name"] == "old-batch-runner"), None)
if retired and retired.get("lastUsedAt") and when(retired["lastUsedAt"]) > when(retired_on):
pass # Something is still calling with it. Revoke it and find out what breaks.It tells you a key was used and when it was last used. It does not say from where, or for what. Treat it as a tripwire worth checking, and name your keys well enough that the answer is obvious.
A readable inventory
const { keys } = await api.keys.list();
const rows = keys.map((k) => ({
name: k.name,
prefix: k.prefix,
age: Math.round((Date.now() - Date.parse(k.createdAt)) / 86_400_000) + "d",
used: k.lastUsedAt
? Math.round((Date.now() - Date.parse(k.lastUsedAt)) / 86_400_000) + "d ago"
: "never",
}));
console.table(rows);from datetime import datetime, timezone
keys = api.keys.list()["keys"]
now = datetime.now(timezone.utc)
def days_since(value): return (now - datetime.fromisoformat(value.replace("Z", "+00:00"))).days
for k in keys:
used = f"{days_since(k['lastUsedAt'])}d ago" if k.get("lastUsedAt") else "never"
print(f"{k['name']:<20} {k['prefix']:<12} {days_since(k['createdAt'])}d {used}")