A key is handed over once, when you create it in your account, and never shown again: what is kept is a hash of it, so a key can be checked and cannot be read back. Lose it and you make another.
A key is created in your account, not from code
There is no method here that makes one, and that is deliberate. A program that can mint keys turns one leaked key into as many as the holder wants, each outliving whatever you revoke — so issuing a credential is something a person does, signed in, and not something a credential can do for itself.
Sign in to your account and create the key there. Then hand it to the program through its environment or your secret store — the program reads it, and never issues one.
The methods
| Method | Returns |
|---|---|
| list() | { ok, keys } — every active key on the account, without its secret |
| revoke(id) | { ok: true }, or 404 when no active key carries that id |
Read and stop: that is the whole surface. It is enough to audit what exists and to cut off what should not, which is what a running program legitimately needs.
It resolves to an object, not an array: read keys from it. Destructure rather than indexing, and nothing surprises you.
The two halves of a key
| What it is | Where it may go | |
|---|---|---|
| The key | The secret. Shown once, at creation, in your account. | A secret store. Nowhere else. |
| The prefix | A short identifier, not a secret. | Configuration, logs, dashboards. |
The prefix is what identifies a key afterwards. Record it when you deploy the key, and you can always tell which row in list() belongs to which process — without ever comparing secrets.
scopes
scopes is recorded with the key and handed back by list(). Treat it as a label: a key's reach is the account's.
Two keys on one account reach the same data, the same storages and the same balance. When a process must not be able to touch something, give it its own account — that is the boundary.
Where to keep one
| Place | Verdict |
|---|---|
| An environment variable, or a secret store | Yes. This is the normal answer. |
| A file on the machine, readable only by the service user | Acceptable, if the machine is not shared. |
| Committed to a repository | No — including a private one, and including a deleted commit. |
| Shipped to a browser or a mobile app | No. Whoever opens it can read it. |
| A CI log, an error report, a support ticket | No. Assume anything printed is kept. |
How many to have
- One per deployment, named after it. Revoking a key then stops exactly one thing, and you know which.
- One per developer machine, separate from production, so it can be revoked without a deployment.
- Not one per user of your app. Your users authenticate with you; your server authenticates with IaGenify.
Rotating one, without downtime
Keys do not expire on their own, so rotation is something you do rather than something that happens. Two of the four steps are yours, in your account; the other two your code can check and finish.
| Step | Where | Why in this order |
|---|---|---|
| 1 · Create the replacement | In your account | Both keys work. Nothing is interrupted. |
| 2 · Deploy it, and its prefix | Your secret store | The program starts using the new one. |
| 3 · Confirm with lastUsedAt | list() | Evidence, rather than hope, that the deployment took. |
| 4 · Revoke the old one | revoke() | Now nothing is left depending on it. |
// Steps 3 and 4, once the new key is deployed.
const { keys } = await api.keys.list();
const fresh = keys.find((k) => k.prefix === process.env.IAGENIFY_KEY_PREFIX);
if (!fresh?.lastUsedAt) throw new Error("the new key has not been used yet");
const previous = keys.find((k) => k.prefix === previousPrefix);
if (previous) await api.keys.revoke(previous.id);import os
# Steps 3 and 4, once the new key is deployed.
keys = api.keys.list()["keys"]
fresh = next((k for k in keys if k["prefix"] == os.environ["IAGENIFY_KEY_PREFIX"]), None)
if not fresh or not fresh.get("lastUsedAt"):
raise RuntimeError("the new key has not been used yet")
previous = next((k for k in keys if k["prefix"] == previous_prefix), None)
if previous:
api.keys.revoke(previous["id"])Step 3 is the one people skip. lastUsedAt is the only evidence that the deployment actually picked up the new key — without it you are revoking the old one on faith.