Skip to main content

Admin User Management

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 '@edgebase/admin';

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

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

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.