Skip to main content

Overview

TrailBase provides comprehensive CLI commands for managing users and administrators. Unlike the admin UI, CLI commands allow you to modify admin users and perform operations that require elevated permissions.

User Commands

All user commands operate on the _user table in the main database. Users can be identified by either email address or UUID.

User Identifiers

Most commands accept a user identifier that can be:
string
User’s email address (e.g., user@example.com)Must contain an @ symbol
string
User’s unique identifier (e.g., 550e8400-e29b-41d4-a716-446655440000)Standard UUID format

Adding Users

user add

Create a new verified user with email and password.
string
required
Email address for the new user. Must be a valid email format and unique.
string
required
Password for the new user. Not checked against password policies, so choose a strong password.
Users created with trail user add are automatically marked as verified and can log in immediately.
The CLI does not enforce password policies. Ensure you use strong passwords when creating users via CLI.

Modifying Users

user change-password

Change a user’s password.
string
required
User identifier (email or UUID).
string
required
New password to set for the user.
Password changes take effect immediately. Active sessions remain valid until their tokens expire.

user change-email

Change a user’s email address.
string
required
User identifier (email or UUID).
string
required
New email address to set for the user. Must be unique.
Email changes do not trigger verification emails. The user can immediately log in with the new email address.

user verify

Change a user’s email verification status.
string
required
User identifier (email or UUID).
boolean
default:"true"
Verification status to set. true to verify, false to unverify.
Unverified users cannot log in until they verify their email or are manually verified via CLI.

Session Management

user invalidate-session

Invalidate all active sessions for a user, forcing re-authentication.
string
required
User identifier (email or UUID).
Example
Active auth tokens remain valid until expiration. Users will need to re-authenticate when their current token expires.
Use cases:
  • User reports compromised account
  • Force logout after password change
  • Security incident response
  • User permission changes require re-authentication

user mint-token

Generate an authentication token for a user.
string
required
User identifier (email or UUID).
Example:
The output is in Bearer token format and can be used directly in Authorization headers for API requests.
Use token with curl:
Use cases:
  • Testing API endpoints
  • Automated scripts requiring authentication
  • Debugging authentication issues
  • Service-to-service authentication
Tokens are sensitive credentials. Handle them securely and never commit them to version control.

Deleting Users

user delete

Permanently delete a user and all associated data.
string
required
User identifier (email or UUID).
This operation is irreversible. All user data will be permanently deleted. Consider backing up the database before deleting users.
What gets deleted:
  • User record from _user table
  • User sessions from _session table
  • User avatar from _user_avatar table
  • Related records (depending on foreign key constraints)
Backup before deletion:

Admin Management

admin list

List all users with admin privileges.
Example output:
Output columns:
  • id - User UUID
  • email - User email address
  • created - Account creation timestamp
  • updated - Last update timestamp

admin promote

Promote a regular user to admin.
string
required
User identifier (email or UUID).
Admin users gain access to the admin UI and all admin API endpoints. Permissions take effect immediately for new sessions.
Admin privileges include:
  • Access to Admin UI (/_admin)
  • Configuration management
  • User management via UI
  • Schema management
  • Log viewing
  • API management

admin demote

Demote an admin user to regular user.
string
required
User identifier (email or UUID).
Demoted users lose admin access immediately for new sessions. Existing sessions may retain admin access until tokens expire.
Unlike the admin UI, the CLI allows you to demote yourself. Ensure you have at least one admin user before demoting all admins.

User Import

user import

Bulk import users from external authentication providers.
string
Path to Auth0 exported users as newline-delimited JSON (NDJSON) file.
boolean
default:"false"
Validate users without importing. Useful for testing before actual import.
Auth0 export format: Auth0 exports users in NDJSON format (one JSON object per line):
Import process:
  1. Validates each user record
  2. Creates users with verified status
  3. Hashes passwords securely
  4. Handles duplicate emails (skips or errors)
  5. Reports import statistics
Always run with --dry-run first to validate the import file before performing the actual import.
Large imports may take time. Monitor the import process and ensure the database isn’t locked by other processes.

Common Workflows

Creating Your First Admin

Handling Forgotten Passwords

Emergency Admin Access

Bulk User Operations

Security Operations

Troubleshooting

User Not Found

Error: Could not find user: user@example.com Solutions:

Duplicate Email

Error: User with email already exists Solutions:

Can’t Demote Last Admin

Issue: Demoting the last admin leaves no way to access admin UI Solution:

Import Fails Partway

Issue: Large import fails after importing some users Solutions:

Database Schema

_user Table

The user table structure:
Query examples: