Skip to content

ClientKeysManager

Client Keys management client

Provides methods for managing client keys for service-to-service authentication. Client keys allow external services to authenticate without user credentials.

const client = createClient({ url: 'http://localhost:8080' })
await client.auth.login({ email: 'user@example.com', password: 'password' })
// Create a client key
const { client_key, key } = await client.management.clientKeys.create({
name: 'Production Service',
scopes: ['read:users', 'write:users'],
rate_limit_per_minute: 100
})
// List client keys
const { client_keys } = await client.management.clientKeys.list()

new ClientKeysManager(fetch): ClientKeysManager

ParameterType
fetchFluxbaseFetch

ClientKeysManager

create(request): Promise<CreateClientKeyResponse>

Create a new client key

ParameterTypeDescription
requestCreateClientKeyRequestClient key configuration

Promise<CreateClientKeyResponse>

Created client key with the full key value (only shown once)

const { client_key, key } = await client.management.clientKeys.create({
name: 'Production Service',
description: 'Client key for production service',
scopes: ['read:users', 'write:users'],
rate_limit_per_minute: 100,
expires_at: '2025-12-31T23:59:59Z'
})
// Store the key securely - it won't be shown again
console.log('Client Key:', key)

delete(keyId): Promise<DeleteClientKeyResponse>

Delete a client key

Permanently removes the client key from the system.

ParameterTypeDescription
keyIdstringClient key ID

Promise<DeleteClientKeyResponse>

Deletion confirmation

await client.management.clientKeys.delete('key-uuid')
console.log('Client key deleted')

get(keyId): Promise<ClientKey>

Get a specific client key by ID

ParameterTypeDescription
keyIdstringClient key ID

Promise<ClientKey>

Client key details

const clientKey = await client.management.clientKeys.get('key-uuid')
console.log('Last used:', clientKey.last_used_at)

list(): Promise<ListClientKeysResponse>

List all client keys for the authenticated user

Promise<ListClientKeysResponse>

List of client keys (without full key values)

const { client_keys, total } = await client.management.clientKeys.list()
client_keys.forEach(key => {
console.log(`${key.name}: ${key.key_prefix}... (expires: ${key.expires_at})`)
})

revoke(keyId): Promise<RevokeClientKeyResponse>

Revoke a client key

Revoked keys can no longer be used but remain in the system for audit purposes.

ParameterTypeDescription
keyIdstringClient key ID

Promise<RevokeClientKeyResponse>

Revocation confirmation

await client.management.clientKeys.revoke('key-uuid')
console.log('Client key revoked')

update(keyId, updates): Promise<ClientKey>

Update a client key

ParameterTypeDescription
keyIdstringClient key ID
updatesUpdateClientKeyRequestFields to update

Promise<ClientKey>

Updated client key

const updated = await client.management.clientKeys.update('key-uuid', {
name: 'Updated Name',
rate_limit_per_minute: 200
})