api.keys

Overview

Keys are what a program authenticates with. Two methods — see them, and stop one. Making one is done in your account.

2 methodsread and revoke onlyfree
Using Python?

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

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.

If you are looking for create(), it is not here

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

MethodReturns
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.

list() answers an envelope

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 isWhere it may go
The keyThe secret. Shown once, at creation, in your account.A secret store. Nowhere else.
The prefixA 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.

Do not use scopes as an isolation boundary

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

PlaceVerdict
An environment variable, or a secret storeYes. This is the normal answer.
A file on the machine, readable only by the service userAcceptable, if the machine is not shared.
Committed to a repositoryNo — including a private one, and including a deleted commit.
Shipped to a browser or a mobile appNo. Whoever opens it can read it.
A CI log, an error report, a support ticketNo. 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.

StepWhereWhy in this order
1 · Create the replacementIn your accountBoth keys work. Nothing is interrupted.
2 · Deploy it, and its prefixYour secret storeThe program starts using the new one.
3 · Confirm with lastUsedAtlist()Evidence, rather than hope, that the deployment took.
4 · Revoke the old onerevoke()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.