SDK
API keys
Manage the caller's API keys through the SDK
Key management lives on vaze.keys. These calls need a client that acts as
a signed-in user whose role holds
api-keys:manage; a client built with an API key gets a 403. Every method
returns the response envelope.
The ApiKey object
type ApiKey = {
id: string;
name: string;
scopes: Scope[]; // capped by the owner's current role on every request
createdAt: string;
lastUsed: string | null;
expiresAt: string | null; // null for a key that never expires
};List keys
const { data } = await vaze.keys.getAll();
// data => { keys: ApiKey[] }, newest firstCreate a key
scopes takes any of files:read, files:write and files:delete that the
caller holds. expiresAt takes a Date or an ISO string; leave it out for a
key that never expires.
const { data, error } = await vaze.keys.create({
name: "Backup script",
scopes: ["files:read", "files:write"],
expiresAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000),
});
// data => { key: ApiKey & { key: string } }
console.log(data?.key.key); // "vz_..."The secret in key.key is only returned here. Store it right away, since the
instance keeps nothing but its hash. A taken name responds 409.
Rename a key
await vaze.keys.rename({ id: "key-id", name: "Nightly backup" });Scopes and expiry are fixed once a key exists. To change them, create a new key and delete the old one.
Delete a key
await vaze.keys.delete("key-id");Anything using the key stops working on its next request.
Vaze