Skip to content

FluxbaseAdmin

Admin client for managing Fluxbase instance

new FluxbaseAdmin(fetch): FluxbaseAdmin

Parameter Type
fetch FluxbaseFetch

FluxbaseAdmin

Property Modifier Type Description
ai public FluxbaseAdminAI AI manager for chatbot and provider management (create, update, delete, sync)
ddl public DDLManager DDL manager for database schema and table operations
emailTemplates public EmailTemplateManager Email template manager for customizing authentication and notification emails
functions public FluxbaseAdminFunctions Functions manager for edge function management (create, update, delete, sync)
impersonation public ImpersonationManager Impersonation manager for user impersonation and audit trail
jobs public FluxbaseAdminJobs Jobs manager for background job management (create, update, delete, sync, monitoring)
management public FluxbaseManagement Management namespace for client keys, webhooks, and invitations
migrations public FluxbaseAdminMigrations Migrations manager for database migration operations (create, apply, rollback, sync)
oauth public FluxbaseOAuth OAuth configuration manager for provider and auth settings
realtime public FluxbaseAdminRealtime Realtime manager for enabling/disabling realtime on tables
rpc public FluxbaseAdminRPC RPC manager for procedure management (create, update, delete, sync, execution monitoring)
serviceKeys public ServiceKeysManager Service keys manager for API key management (list, create, rotate, revoke)
settings public FluxbaseSettings Settings manager for system and application settings
storage public FluxbaseAdminStorage Storage manager for bucket and object management (list, create, delete, signed URLs)

clearToken(): void

Clear admin token

void


deleteUser(userId, type?): Promise<DataResponse<DeleteUserResponse>>

Delete a user

Permanently deletes a user and all associated data

Parameter Type Default value Description
userId string undefined User ID to delete
type "app" | "dashboard" "app" User type (‘app’ or ‘dashboard’)

Promise<DataResponse<DeleteUserResponse>>

Deletion confirmation

await admin.deleteUser('user-uuid');
console.log('User deleted');

getHealth(): Promise<DataResponse<HealthResponse>>

Get system health status

Promise<DataResponse<HealthResponse>>

Health status including database and realtime service status

const { data, error } = await admin.getHealth();
if (data) {
console.log('Status:', data.status);
console.log('Database:', data.services.database);
console.log('Realtime:', data.services.realtime);
}

getSetupStatus(): Promise<DataResponse<AdminSetupStatusResponse>>

Check if initial admin setup is needed

Promise<DataResponse<AdminSetupStatusResponse>>

Setup status indicating if initial setup is required

const status = await admin.getSetupStatus();
if (status.needs_setup) {
console.log('Initial setup required');
}

getToken(): string | null

Get current admin token

string | null


getUserById(userId, type?): Promise<DataResponse<EnrichedUser>>

Get a user by ID

Fetch a single user’s details by their user ID

Parameter Type Default value Description
userId string undefined User ID to fetch
type "app" | "dashboard" "app" User type (‘app’ or ‘dashboard’)

Promise<DataResponse<EnrichedUser>>

User details with metadata

// Get an app user
const user = await admin.getUserById('user-123');
// Get a dashboard user
const dashboardUser = await admin.getUserById('admin-456', 'dashboard');
console.log('User email:', dashboardUser.email);
console.log('Last login:', dashboardUser.last_login_at);

inviteUser(request, type?): Promise<DataResponse<InviteUserResponse>>

Invite a new user

Creates a new user and optionally sends an invitation email

Parameter Type Default value Description
request InviteUserRequest undefined User invitation details
type "app" | "dashboard" "app" User type (‘app’ or ‘dashboard’)

Promise<DataResponse<InviteUserResponse>>

Created user and invitation details

const response = await admin.inviteUser({
email: 'newuser@example.com',
role: 'user',
send_email: true
});
console.log('User invited:', response.user.email);
console.log('Invitation link:', response.invitation_link);

listUsers(options?): Promise<DataResponse<ListUsersResponse>>

List all users

Parameter Type Description
options ListUsersOptions Filter and pagination options

Promise<DataResponse<ListUsersResponse>>

List of users with metadata

// List all users
const { users, total } = await admin.listUsers();
// List with filters
const result = await admin.listUsers({
exclude_admins: true,
search: 'john',
limit: 50,
type: 'app'
});

login(request): Promise<DataResponse<AdminAuthResponse>>

Admin login

Authenticate as an admin user

Parameter Type Description
request AdminLoginRequest Login request containing email and password

Promise<DataResponse<AdminAuthResponse>>

Authentication response with tokens

const response = await admin.login({
email: 'admin@example.com',
password: 'password123'
});
// Token is automatically set in the client
console.log('Logged in as:', response.user.email);

logout(): Promise<VoidResponse>

Admin logout

Invalidates the current admin session

Promise<VoidResponse>

await admin.logout();
localStorage.removeItem('admin_token');

me(): Promise<DataResponse<AdminMeResponse>>

Get current admin user information

Promise<DataResponse<AdminMeResponse>>

Current admin user details

const { user } = await admin.me();
console.log('Logged in as:', user.email);
console.log('Role:', user.role);

refreshToken(request): Promise<DataResponse<AdminRefreshResponse>>

Refresh admin access token

Parameter Type Description
request AdminRefreshRequest Refresh request containing the refresh token

Promise<DataResponse<AdminRefreshResponse>>

New access and refresh tokens

const refreshToken = localStorage.getItem('admin_refresh_token');
const response = await admin.refreshToken({ refresh_token: refreshToken });
// Update stored tokens
localStorage.setItem('admin_token', response.access_token);
localStorage.setItem('admin_refresh_token', response.refresh_token);

resetUserPassword(userId, type?): Promise<DataResponse<ResetUserPasswordResponse>>

Reset user password

Generates a new password for the user and optionally sends it via email

Parameter Type Default value Description
userId string undefined User ID
type "app" | "dashboard" "app" User type (‘app’ or ‘dashboard’)

Promise<DataResponse<ResetUserPasswordResponse>>

Reset confirmation message

const response = await admin.resetUserPassword('user-uuid');
console.log(response.message);

setToken(token): void

Set admin authentication token

Parameter Type
token string

void


setup(request): Promise<DataResponse<AdminAuthResponse>>

Perform initial admin setup

Creates the first admin user and completes initial setup. This endpoint can only be called once.

Parameter Type Description
request AdminSetupRequest Setup request containing email, password, and name

Promise<DataResponse<AdminAuthResponse>>

Authentication response with tokens

const response = await admin.setup({
email: 'admin@example.com',
password: 'SecurePassword123!',
name: 'Admin User'
});
// Store tokens
localStorage.setItem('admin_token', response.access_token);

updateUserRole(userId, role, type?): Promise<DataResponse<EnrichedUser>>

Update user role

Changes a user’s role

Parameter Type Default value Description
userId string undefined User ID
role string undefined New role
type "app" | "dashboard" "app" User type (‘app’ or ‘dashboard’)

Promise<DataResponse<EnrichedUser>>

Updated user

const user = await admin.updateUserRole('user-uuid', 'admin');
console.log('User role updated:', user.role);