ApiKeysResource
Access via urblock.apiKeys.
Manage API keys programmatically. Requires JWT authentication (not API key auth).
Methods
create(params)
Create a new API key.
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Human-readable label |
type | string | Yes | "secret" or "publishable" |
const key = await urblock.apiKeys.create({
name: "Production Backend",
type: "secret",
});
console.log(key.id); // "ak_abc123"
console.log(key.key); // "sk_live_..." — shown only once
Returns: ApiKeyResponse
list()
List all API keys for the current tenant.
const keys = await urblock.apiKeys.list();
keys.data.forEach((k) => console.log(k.name, k.type, k.last_used_at));
Returns: ListResponse<ApiKeyResponse>
revoke(id)
Permanently revoke an API key.
await urblock.apiKeys.revoke("ak_abc123");
Returns: ApiKeyResponse (with revoked: true)
rotate(id)
Rotate an API key — creates a new secret and revokes the old one.
const rotated = await urblock.apiKeys.rotate("ak_abc123");
console.log(rotated.key); // new secret — shown only once
Returns: ApiKeyResponse