CLI commands
Please note that in order to use CLI commands, you will need SSH Access to the server as well as an Astrakit admin acount on your Instance and when prompted, you will need to log in using your account data such as email, pasword and 2FA token
You can access a variety of commands using the Admin-CLI that's provided with the Astrakit API on github. You will find a command and instruction list on this page. Please note that the commands may have been restricted or modified by your instance owner!
Table of Contents
- Authentication
- User Management
- Account Moderation
- Administrative Actions
- Badge Management
- Push Notifications
- System Commands
- Terminal Management
- Examples
Authentication
The Admin CLI requires secure authentication with:
- Admin email address
- Account password
- 2FA code from authenticator app
All administrators are required to have 2FA enabled on their accounts for additional security.
User Management
Finding Users
user find <username/email/uuid>
Displays detailed information about a specific user, including:
- UUID, username, email address
- Account status and creation date
- Last seen timestamp
- Admin status
- 2FA status
- Astrabits balance
- Purchase history summary
- Profile information
Listing Users
user list [limit] [offset]
Lists users in the system with pagination:
limit: Maximum number of users to display (default: 10)offset: Number of users to skip (default: 0)
Example: user list 20 40 displays users 41-60
Account Moderation
Deleting Users
delete <username/email/uuid>
Permanently deletes a user account. This:
- Removes the account from the database
- Deletes all user sessions
- Removes user files from storage
- Sends notification email to the user
Warning: This action cannot be undone.
Blocking Users
block <username/email/uuid>
or
ban <username/email/uuid>
Bans a user from the platform. This:
- Sets their account status to "banned"
- Invalidates all active sessions
- Prevents future logins
- Sends notification email to the user
Unblocking Users
unblock <username/email/uuid>
or
unban <username/email/uuid>
Unbans a previously banned user. This:
- Sets their account status back to "active"
- Allows them to log in again
- Sends notification email to the user
Administrative Actions
Granting Admin Privileges
admin grant <username/email/uuid>
Promotes a user to administrator status. This:
- Updates their admin flag in the database
- Adds them to the admins table
- Sends notification email to the user
Revoking Admin Privileges
admin revoke <username/email/uuid>
Removes administrator privileges from a user. This:
- Updates their admin flag in the database
- Removes them from the admins table
- Sends notification email to the user
Note: You cannot revoke your own admin privileges.
Badge Management
Listing Badges
badge list
Shows a list of all badges in the system with their IDs, titles, icons, and sort orders.
Badge Details
badge info <badge_id>
Shows detailed information about a specific badge including:
- Title, description, icon, color
- Creation date and creator
- Sort order
- List of users who have been assigned this badge
Creating Badges
badge create
Interactive command to create a new badge, prompting for:
- Title
- Description
- Icon (optional, defaults to "military_tech")
- Color (optional, defaults to "#3b82f6")
- Sort order (optional, defaults to 0)
Editing Badges
badge edit <badge_id>
Interactive command to edit an existing badge, allowing changes to:
- Title
- Description
- Icon
- Color
- Sort order
Deleting Badges
badge delete <badge_id>
Deletes a badge from the system, also removing all user assignments.
Badge Assignments
badge assign <badge_id> <username/email/uuid>
Assigns a badge to a user, sending them a push notification.
badge unassign <badge_id> <username/email/uuid>
Removes a badge from a user.
badge user <username/email/uuid>
Lists all badges assigned to a specific user.
Push Notifications
Sending to a User
push send <username/email/uuid> <message>
Sends a push notification to a specific user.
Broadcasting
push broadcast <message>
Sends a push notification to all users with registered devices.
System Commands
Server Status
status
Displays detailed information about the API server status, including:
- API version and uptime
- Server load and memory usage
- Database status and statistics
- Number of registered users
- Number of active sessions
- Maintenance mode status
- CLI memory usage and goroutine count
Shutdown Server
shutdown
Gracefully shuts down the API server:
- Confirms the action before proceeding
- Logs the shutdown action including admin name and timestamp
- Sends a termination signal to the API process
- Removes the PID file after shutdown
Warning: This will terminate the API for all users. The CLI will remain active until you exit it separately.
Terminal Management
Clearing the Screen
clear
Clears the terminal screen to improve readability:
- Works on both Windows and Unix-like systems
- Re-displays the CLI header after clearing
Logging Out
logout
Logs out of the current admin session:
- Invalidates the current admin CLI session in the database
- Logs the logout action
- Returns to the authentication prompt
- Allows another admin to log in without restarting the CLI
Exiting the CLI
exit
or
quit
Safely exits the Admin CLI interface completely.
Examples
Finding a Specific User
astrakit-admin> user find john.doe@example.com
Banning a User
astrakit-admin> block spammer123
Listing Recent Users
astrakit-admin> user list 25 0
Checking Server Status
astrakit-admin> status
Clearing the Terminal
astrakit-admin> clear
Logging Out
astrakit-admin> logout
Gracefully Shutting Down the Server
astrakit-admin> shutdown
Granting Admin Privileges
astrakit-admin> admin grant jane.smith@example.com
Creating a New Badge
astrakit-admin> badge create
Assigning a Badge
astrakit-admin> badge assign 5 user123
Broadcasting a Push Notification
astrakit-admin> push broadcast Server maintenance in 30 minutes