APIKeysManager
API Keys management client
Provides methods for managing API keys for service-to-service authentication. API keys allow external services to authenticate without user credentials.
Example
Section titled “Example”const client = createClient({ url: 'http://localhost:8080' })await client.auth.login({ email: 'user@example.com', password: 'password' })
// Create an API keyconst { api_key, key } = await client.management.apiKeys.create({ name: 'Production Service', scopes: ['read:users', 'write:users'], rate_limit_per_minute: 100})
// List API keysconst { api_keys } = await client.management.apiKeys.list()Constructors
Section titled “Constructors”new APIKeysManager()
Section titled “new APIKeysManager()”new APIKeysManager(
fetch):APIKeysManager
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fetch | FluxbaseFetch |
Returns
Section titled “Returns”Methods
Section titled “Methods”create()
Section titled “create()”create(
request):Promise<CreateAPIKeyResponse>
Create a new API key
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
request | CreateAPIKeyRequest | API key configuration |
Returns
Section titled “Returns”Promise<CreateAPIKeyResponse>
Created API key with the full key value (only shown once)
Example
Section titled “Example”const { api_key, key } = await client.management.apiKeys.create({ name: 'Production Service', description: 'API 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 againconsole.log('API Key:', key)delete()
Section titled “delete()”delete(
keyId):Promise<DeleteAPIKeyResponse>
Delete an API key
Permanently removes the API key from the system.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
keyId | string | API key ID |
Returns
Section titled “Returns”Promise<DeleteAPIKeyResponse>
Deletion confirmation
Example
Section titled “Example”await client.management.apiKeys.delete('key-uuid')console.log('API key deleted')get(
keyId):Promise<APIKey>
Get a specific API key by ID
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
keyId | string | API key ID |
Returns
Section titled “Returns”Promise<APIKey>
API key details
Example
Section titled “Example”const apiKey = await client.management.apiKeys.get('key-uuid')console.log('Last used:', apiKey.last_used_at)list()
Section titled “list()”list():
Promise<ListAPIKeysResponse>
List all API keys for the authenticated user
Returns
Section titled “Returns”Promise<ListAPIKeysResponse>
List of API keys (without full key values)
Example
Section titled “Example”const { api_keys, total } = await client.management.apiKeys.list()
api_keys.forEach(key => { console.log(`${key.name}: ${key.key_prefix}... (expires: ${key.expires_at})`)})revoke()
Section titled “revoke()”revoke(
keyId):Promise<RevokeAPIKeyResponse>
Revoke an API key
Revoked keys can no longer be used but remain in the system for audit purposes.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
keyId | string | API key ID |
Returns
Section titled “Returns”Promise<RevokeAPIKeyResponse>
Revocation confirmation
Example
Section titled “Example”await client.management.apiKeys.revoke('key-uuid')console.log('API key revoked')update()
Section titled “update()”update(
keyId,updates):Promise<APIKey>
Update an API key
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
keyId | string | API key ID |
updates | UpdateAPIKeyRequest | Fields to update |
Returns
Section titled “Returns”Promise<APIKey>
Updated API key
Example
Section titled “Example”const updated = await client.management.apiKeys.update('key-uuid', { name: 'Updated Name', rate_limit_per_minute: 200})