Retorno
{
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",
}
],
}idstringQua revoke()prende. Aparece qui e nùcun altro.
namestringIl nome dato quando la chiave è stata creata, in tuo conto. Non unico — due chiues possono dividere una.
prefixstringIdentificatori corto. Itèra la forma in cui si combina una tecla memorizzata a una fila.
scopesstring[]L'etiqueta registrata con la tecla. ["*"] quando non era dada.
lastUsedAtstring|nullActualized ogni volta che la chiave è usat. null significa che nunca ha fost.
expiresAtstring|nullUna caduca, quando la tecla porta uno. null altrimenti.
isActivebooleanRevoking sets esto a false.
createdAtstringQuando fu creata, prima la prima novella.
Le dates sono ISO stringhes, quindi Date.parse le lège e una comparazion di stringhes simples trie. Chiaves revocate non sono restituites: la consulta è delimitata a chaves actives del conto.
Quale fila è la chave che tengo
Mai comparando la chiave in sé — la lista non ha alcun segreto contra contra. Met a tasto il prefix al titulo quando lo implora, e la corrispondenza è exacta e inofensiv.
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")L'audito di questo ti da
lastUsedAt è l'unico campo qui vi dice qualcosa che non sapevi.
Ce non è usat
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'}")Una chiave che non usa è una chiave che può essere revocata, e ogni che si retira è una cosa meno a filtrare. Una chiave che ha nunca è usata è generalmente una rotazione che è creata e mai implementata.
Ce è usat quando non deve ser
// 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.Te dice una chiave è stato usat e quando è stato usat ultima. Non dice da da da où, o per què. Trattalo come un tripwire vale la pena check, e nomeare le chiavi abbastanza bene che la risposta è obvia.
Un inventari legìbile
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}")