Skip to main content

Admin User Management

Beta

This feature is in beta. Core behavior is stable and ready to try, but some APIs or configuration may still evolve before general availability.

Server-side user management via the Service Key. These operations bypass access rules.

info

Admin Auth is available in all Admin SDKs. See Admin SDK for details.

Setup

import { createAdminClient } from '@edge-base/admin';

const admin = createAdminClient('https://my-app.edgebase.fun', {
serviceKey: process.env.EDGEBASE_SERVICE_KEY,
});
warning

Never use the Service Key in client-side code. It has full admin access to your backend.

Operational Notes

  • Initial admin bootstrap is a one-time operation. Outside the local npx edgebase dev workflow, use npx edgebase admin bootstrap or the guided deploy / docker run flow instead of relying on a browser setup page.
  • To change an admin password later, use the dashboard settings page or npx edgebase admin reset-password.
  • To move an admin account to a new email, add a new admin with the new email first, confirm that it can sign in, then remove the old admin. This avoids locking yourself out during the transition.

Operations

// List users
const users = await admin.auth.listUsers({ limit: 50 });

// Get user
const user = await admin.auth.getUser('user-id');

// Create user (server-side)
const newUser = await admin.auth.createUser({
email: 'admin@example.com',
password: 'securePassword',
displayName: 'Admin User',
role: 'admin',
});

// Update user
await admin.auth.updateUser('user-id', {
displayName: 'New Name',
role: 'moderator',
});

// Delete user
await admin.auth.deleteUser('user-id');

// Set custom claims (included in JWT)
await admin.auth.setCustomClaims('user-id', {
plan: 'pro',
features: ['analytics', 'export'],
});

// Revoke all sessions (force re-login)
await admin.auth.revokeAllSessions('user-id');

Custom Claims

Claims set via setCustomClaims() are included in the user's JWT under the custom namespace:

{
"sub": "user-id",
"iss": "edgebase:user",
"exp": 1234567890,
"custom": {
"plan": "pro",
"features": ["analytics", "export"]
}
}

Access in access rules: read(auth) { return auth?.custom?.plan === 'pro' }

REST API

EndpointMethodDescription
/api/auth/admin/usersGETList users
/api/auth/admin/users/:idGETGet user
/api/auth/admin/usersPOSTCreate user
/api/auth/admin/users/:idPATCHUpdate user
/api/auth/admin/users/:idDELETEDelete user
/api/auth/admin/users/:id/claimsPUTSet custom claims
/api/auth/admin/users/:id/revokePOSTRevoke sessions

All endpoints require the X-EdgeBase-Service-Key header.