{% extends "base.html" %} {# --- Page Title --- #} {% block title %}API Quick Reference - {{ super() }}{% endblock %} {# --- Specific Styles for API Docs --- #} {% block head_styles %} {# Add specific styles for API docs elements on top of base CSS #} {% endblock %} {# --- Main Content Area --- #} {% block content %}
This document provides a concise overview of the HTTP API endpoints for interacting with the Bedrock Server Manager.
{# --- Table of Contents --- #} {# --- Introduction Section (copied from MD) --- #}All endpoint paths are relative to the base URL where the manager's web server is running. Replace http://
with the actual address. The default port is 11325
(configurable via the WEB_PORT
setting).
Most API endpoints require authentication. This is done by providing a JSON Web Token (JWT) obtained from the /api/login
endpoint. Include the token in the Authorization
header as a Bearer token:
Authorization: Bearer YOUR_JWT_TOKEN
The token expiration duration is configurable via the TOKEN_EXPIRES_WEEKS
setting, defaulting to 4 weeks.
For requests that include data in the body (POST, PUT), the Content-Type
header should be set to application/json
. Responses from the API will typically have a Content-Type
of application/json
.
200 OK
, 201 Created
with a JSON body like:
{
"status": "success",
"message": "Operation completed successfully.",
"data_key": "optional_data"
}
(Specific data_key
names vary by endpoint)
4xx
(Client Error) or 5xx
(Server Error) with a JSON body like:
{
"status": "error",
"message": "A description of the error.",
"errors": { // Optional: Field-specific validation errors
"field_name": "Specific error for this field."
}
}
Common error codes:
400 Bad Request
: Invalid input, missing parameters, validation failed, invalid format (e.g., not JSON).401 Unauthorized
: Authentication token missing or invalid (for JWT protected routes).403 Forbidden
: Authenticated user lacks permission (or OS mismatch for platform-specific endpoints like scheduling).404 Not Found
: Server, task, file, or endpoint not found.500 Internal Server Error
: An unexpected error occurred on the server during processing (e.g., file operation failure, configuration issue).501 Not Implemented
: Feature not supported on the current OS (e.g., sending commands on Windows).To enhance robustness and provide immediate feedback, the application implements a global pre-request validation check. This check runs before the actual route handler for most requests involving a specific server instance.
@app.before_request
decorator./server//
, where
is a segment in the path./server/MyServer/status_info
, /api/server/AnotherServer/stop
./server/install
/api/server/install
is extracted.validate_server_exist
is called./api/...
): Aborted with 404 Not Found
.
{ "status": "error", "message": "Server '' not found." }
/
) with a flash message.500 Internal Server Error
.
{ "status": "error", "message": "Internal server error during server validation." }
/api/server//...
for a non-existent server will get an immediate 404
.server_name
corresponds to a valid, existing server./api/login
Authenticates using username/password and returns a JWT.
None.
application/json
):{
"username": "your_username",
"password": "your_plain_text_password"
}
username
(string)(Required)password
(string)(Required){ "access_token": "YOUR_JWT_TOKEN" }
/api/servers
Lists all detected server instances with configured status/version.
Required.
{
"status": "success",
"servers": [
{ "name": "server1", "status": "RUNNING", "version": "1.20.81.01" },
{ "name": "server2", "status": "STOPPED", "version": "1.20.73.02" }
// ...
]
}
(May include an optional message
field if errors occurred reading some server configs.)
/api/server/{server_name}/world_name
Gets the level-name
from server.properties
.
Required.
server_name
(string)(Required){ "status": "success", "world_name": "Bedrock level" }
/api/server/{server_name}/running_status
Checks if the server process is running.
Required.
server_name
(string)(Required){ "status": "success", "is_running": true | false }
/api/server/{server_name}/config_status
Gets status stored in manager's config file for the server.
Required.
server_name
(string)(Required){ "status": "success", "config_status": "Installed | Stopped | Running | ..." }
/api/server/{server_name}/version
Gets installed version stored in manager's config file.
Required.
server_name
(string)(Required){ "status": "success", "installed_version": "1.20.81.01 | UNKNOWN" }
/api/server/{server_name}/validate
Checks if server directory and executable exist.
Required.
server_name
(string)(Required)200 OK
: Server exists. {"status": "success", "message": "Server '...' exists and is valid."}
404 Not Found
: Directory or executable missing. {"status": "error", "message": "Server directory '...' not found."}
/api/server/{server_name}/status_info
Gets runtime process info (PID, CPU, Mem, Uptime) if running.
Note: CPU % is relative to previous check (first check is 0%).
Required.
server_name
(string)(Required){
"status": "success",
"process_info": { "pid": ..., "cpu_percent": ..., "memory_mb": ..., "uptime": "..." }
}
{
"status": "success", "process_info": null, "message": "Server '...' is not running."
}
/api/server/{server_name}/start
Starts the specified server instance.
Required.
server_name
(string)(Required){"status": "success", "message": "Server '...' started successfully."}
/api/server/{server_name}/stop
Stops the specified server instance (graceful if possible).
Required.
server_name
(string)(Required){"status": "success", "message": "Server '...' stopped successfully."}
or
{"status": "success", "message": "Server '...' was already stopped."}
/api/server/{server_name}/restart
Restarts the server (stops if running, then starts).
Required.
server_name
(string)(Required){"status": "success", "message": "Server '...' restarted successfully."}
or
{"status": "success", "message": "Server '...' was not running and was started."}
/api/server/{server_name}/send_command
Sends command to running server console (Linux: screen, Windows: Named Pipes).
Required.
server_name
(string)(Required)application/json
):{ "command": "your server command" }
command
(string)(Required){"status": "success", "message": "Command '...' sent successfully."}
/api/server/{server_name}/update
Checks for and installs latest/preview/specific version based on server config.
Required.
server_name
(string)(Required){"status": "success", "updated": true, "new_version": "...", "message": "Server '...' update process completed. New version: ..." }
{"status": "success", "updated": false, "new_version": "...", "message": "Server is already up-to-date." }
/api/server/{server_name}/delete
Irreversibly deletes server instance (installation, config, backups).
Required.
server_name
(string)(Required){"status": "success", "message": "All data for server '...' deleted successfully."}
/api/server/{server_name}/backups/prune
Deletes old backups, keeping specified number.
Required.
server_name
(string)(Required)application/json
, optional):{ "keep": number }
keep
(integer)(Optional): Defaults to `BACKUP_KEEP` setting.{"status": "success", "message": "Backup pruning completed for server '...'."}
/api/server/{server_name}/backup/action
Triggers a backup (world, config file, or all).
Required.
server_name
(string)(Required)application/json
):{"backup_type": "world"}
{"backup_type": "config", "file_to_backup": "relative/path/file.json"}
{"backup_type": "all"}
backup_type
(string)(Required)file_to_backup
(string)(Required if `type` is `config`){"status": "success", "message": "... backup completed successfully ..."}
/api/server/{server_name}/restore/action
Overwrites current files to restore world or config from specific backup.
Required.
server_name
(string)(Required)application/json
):{"restore_type": "world", "backup_file": "/full/path/to/backup.mcworld"}
{"restore_type": "config", "backup_file": "/full/path/to/config_backup.json"}
restore_type
(string)(Required): `"world"` or `"config"`.backup_file
(string)(Required): Full path (must be within `BACKUP_DIR`).{"status": "success", "message": "Restoration from '...' (type: ...) completed successfully."}
/api/server/{server_name}/restore/all
Overwrites current files to restore world and standard configs from *latest* backups.
Required.
server_name
(string)(Required){"status": "success", "message": "Restore all completed successfully for server '...'."}
/api/server/{server_name}/world/export
Exports the server's current world to a .mcworld
file in the content/worlds
directory.
Required.
server_name
(string)(Required){
"status": "success",
"message": "World for server '...' exported successfully as '....mcworld'.",
"export_file": "/full/path/to/content/worlds/....mcworld"
}
/api/server/{server_name}/world/install
Overwrites current world to install .mcworld
from content/worlds
dir.
Required.
server_name
(string)(Required)application/json
):{ "filename": "relative/path/to/world.mcworld" }
filename
(string)(Required): Path relative to `content/worlds`.{"status": "success", "message": "World '...' installed successfully for server '...'."}
/api/server/{server_name}/addon/install
Installs .mcpack
/.mcaddon
from content/addons
dir into server's world.
Required.
server_name
(string)(Required)application/json
):{ "filename": "relative/path/to/addon.mcpack" }
filename
(string)(Required): Path relative to `content/addons`.{"status": "success", "message": "Addon '...' installed successfully for server '...'."}
/api/players/scan
Scans all server logs for player connections, updates central players.json
.
Required.
{ "status": "success", "players_found": true|false, "message": "Player scan completed..." }
/api/server/{server_name}/allowlist
Gets content of server's allowlist.json
.
Required.
server_name
(string)(Required){
"status": "success",
"existing_players": [ { "ignoresPlayerLimit": ..., "name": "..." }, ... ],
"message": "Successfully retrieved X players from allowlist."
}
/api/server/{server_name}/allowlist/add
Adds players to allowlist.json
(does not remove existing).
Required.
server_name
(string)(Required)application/json
):{
"players": ["Player1", "Player2"],
"ignoresPlayerLimit": false | true
}
players
(list[string])(Required)ignoresPlayerLimit
(boolean)(Optional, default: false){"status": "success", "message": "Allowlist saved successfully with X player(s)."}
or
{"status": "success", "message": "No new players provided or all provided players were duplicates/invalid."}
/api/server/{server_name}/allowlist/player/{player_name}
Removes a player (case-insensitive) from the server's allowlist.json
file.
Required.
server_name
(string)(Required)player_name
(string)(Required): The player name to remove.{
"status": "success",
"message": "Player '...' removed successfully..."
}
Or if player not found:
{
"status": "success",
"message": "Player '...' not found in the allowlist..."
}
/api/server/{server_name}/permissions
Updates player permission levels in permissions.json
.
Required.
server_name
(string)(Required)application/json
):{
"permissions": {
"XUID_string": "visitor | member | operator",
...
}
}
permissions
(object)(Required): Map of XUIDs (string) to levels (string).{"status": "success", "message": "Permissions updated successfully for X player(s) ..."}
or
{"status": "success", "message": "No valid permission changes submitted."}
/api/server/{server_name}/properties
Updates specified allowed keys in server.properties
.
Required.
server_name
(string)(Required)application/json
):{ "property-key": "new-value", ... }
See full docs for list of allowed keys.
{"status": "success", "message": "Server properties for '...' updated successfully."}
/api/server/{server_name}/service
Configures OS-specific service settings (Linux: systemd; Windows: config flag).
Required.
server_name
(string)(Required)application/json
):{ "autoupdate": boolean, "autostart": boolean }
{ "autoupdate": boolean }
autoupdate
(boolean)(Required)autostart
(boolean)(Required, Linux only){"status": "success", "message": "Systemd service created and enabled successfully."}
(Linux Example)
{"status": "success", "message": "Autoupdate setting for '...' updated to true."}
(Windows Example)
/api/downloads/prune
Deletes old downloaded server archives from specified directory.
Required.
application/json
):{
"directory": "/absolute/path/to/cache",
"keep": number
}
directory
(string)(Required)keep
(integer)(Optional): Defaults to `DOWNLOAD_KEEP` setting.{"status": "success", "message": "Download cache pruned successfully for '...'."}
/api/server/install
Installs new server instance. Requires confirmation if server name exists and `overwrite` is false.
Required.
application/json
):{
"server_name": "NewServer",
"server_version": "LATEST | PREVIEW | 1.x.y.z",
"overwrite": false | true
}
server_name
(string)(Required)server_version
(string)(Required)overwrite
(boolean)(Optional, default: false)201 Created
(New/Overwrite): {
"status": "success", "server_name": "...", "version": "...", "message": "...", "next_step_url": "..."
}
200 OK
(Confirmation Needed): {
"status": "confirm_needed", "message": "Server '...' already exists...", "server_name": "...", "server_version": "..."
}
Note: These endpoints interact with Linux cron
or Windows Task Scheduler based on the host OS.
/api/server/{server_name}/cron_scheduler/add
(Linux Only)Adds raw cron job line for manager's user.
Required.
Linux Only.
server_name
(string)(Required)application/json
):{ "new_cron_job": "0 3 * * * /path/to/cmd --args" }
new_cron_job
(string)(Required){"status": "success", "message": "Cron job added successfully."}
/api/server/{server_name}/cron_scheduler/modify
(Linux Only)Replaces existing cron job line by exact match.
Required.
Linux Only.
server_name
(string)(Required)application/json
):{
"old_cron_job": "exact old string",
"new_cron_job": "replacement string"
}
old_cron_job
(string)(Required)new_cron_job
(string)(Required){"status": "success", "message": "Cron job modified successfully."}
or
{"status": "success", "message": "No modification needed, jobs are identical."}
/api/server/{server_name}/cron_scheduler/delete
(Linux Only)Deletes cron job line by exact match.
Required.
Linux Only.
server_name
(string)(Required)cron_string
(string)(Required): URL-encoded exact string of job to delete.{"status": "success", "message": "Cron job deleted successfully (if it existed)."}
/api/server/{server_name}/task_scheduler/add
(Windows Only)Creates new Windows scheduled task.
Required.
Windows Only.
server_name
(string)(Required)application/json
):{
"command": "backup-all | update-server | ...",
"triggers": [ { "type": "Daily|Weekly|...", "start": "ISO8601", ... } ]
}
command
(string)(Required): See full docs for list.triggers
(list[object])(Required): See full docs for trigger structure.{
"status": "success",
"message": "Windows task '...' created successfully.",
"created_task_name": "..."
}
/api/server/{server_name}/task_scheduler/details
(Windows Only)Gets details by parsing task's stored XML file.
Required.
Windows Only.
server_name
(string)(Required)application/json
):{ "task_name": "full_task_name" }
task_name
(string)(Required){
"status": "success",
"task_details": { "command_path": "...", "command_args": "...", "base_command": "...", "triggers": [...] }
}
/api/server/{server_name}/task_scheduler/task/{task_name}
(Windows Only)Modifies task by deleting old (task_name
) and creating new based on body.
Required.
Windows Only.
server_name
(string)(Required)task_name
(string)(Required): Task to replace (URL encode if needed).application/json
):Same as "Add Windows Task" body, defining the new task.
{
"status": "success",
"message": "Windows task modified successfully.",
"new_task_name": "..."
}
/api/server/{server_name}/task_scheduler/task/{task_name}
(Windows Only)Deletes Windows task and its associated XML file.
Required.
Windows Only.
server_name
(string)(Required)task_name
(string)(Required): Task to delete (URL encode if needed).{
"status": "success",
"message": "Task '...' and its definition file deleted successfully."
}