### Start Crafty Service Source: https://docs.craftycontrol.com/pages/getting-started/installation/linux?q= If a service file was added during installation, use this command to start the Crafty service. This assumes you have systemd or a similar init system. ```bash sudo systemctl start crafty ``` -------------------------------- ### Start Server Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Starts a server instance. ```APIDOC ## POST /servers/{serverID}/start ### Description Starts a server instance. ### Method POST ### Endpoint /servers/{serverID}/start ### Parameters #### Path Parameters - **serverID** (string) - Required - Target server's ID. ### Response #### Success Response (200) - **status** (string) - Example: ok #### Response Example { "status": "ok" } ``` -------------------------------- ### One-Line Crafty Installation Script Source: https://docs.craftycontrol.com/pages/getting-started/installation/linux?q= This command clones the Crafty installer repository and executes the installation script. It automates the download and setup process for Crafty. ```bash git clone https://gitlab.com/crafty-controller/crafty-installer-4.0.git && \ cd crafty-installer-4.0 && \ sudo ./install_crafty.sh ``` -------------------------------- ### SWAG Stack Example (Docker Compose) Source: https://docs.craftycontrol.com/pages/getting-started/proxies?q= This example demonstrates a Docker Compose setup for SWAG (Secure Web Application Gateway) with Crafty. It includes environment variable configurations for timezone, user IDs, and domain settings. ```yaml TZ="Europe/London" USER_ID=1000 GROUP_ID=1000 URL=myexampledomain.com SUBDOMAINS="mcdash" ONLY_SUBDOMAINS=true EMAIL=admin.contact@email.com ``` -------------------------------- ### Example Forge Server Execution Command Source: https://docs.craftycontrol.com/pages/getting-started/installation/docker This is an example of a server execution command for a Forge server. Do not copy this directly; adapt it based on your specific Forge installer's .bat/.sh file, excluding environment variables like '%_' or '$@'. ```bash java -Xms4000M -Xmx4000M @libraries/net/minecraftforge/forge/1.18.2-40.1.68/unix_args.txt nogui ``` -------------------------------- ### Install OpenJDK 8 Source: https://docs.craftycontrol.com/pages/getting-started/installation/macos?q= Installs OpenJDK 8 using Homebrew Cask. Java is required for running Minecraft servers. ```bash brew install --cask homebrew/cask-versions/adoptopenjdk8 ``` -------------------------------- ### Install Crafty Windows Service with PowerShell Source: https://docs.craftycontrol.com/pages/getting-started/installation/windows?q= Use this PowerShell script to install the Crafty Windows Service. It handles user creation and startup configuration. ```powershell InstallService.ps1 ``` -------------------------------- ### Switch to Crafty User Source: https://docs.craftycontrol.com/pages/getting-started/installation/linux?q= After installation, switch to the 'crafty' user to run the application manually. This is necessary if you did not install Crafty in the default directory. ```bash sudo su crafty ``` -------------------------------- ### Build and Start Crafty with Docker Compose Source: https://docs.craftycontrol.com/pages/getting-started/installation/docker Builds the Crafty Docker image (if not already built) and starts the services defined in docker-compose.yml in detached mode, then follows the logs. Use this when you have modified the Dockerfile. ```bash docker-compose up -d --build && docker-compose logs -f ``` -------------------------------- ### Install Git and Python 3 Source: https://docs.craftycontrol.com/pages/getting-started/installation/macos?q= Installs Git and Python 3 using Homebrew. These are required for managing code repositories and running Python applications. ```bash brew install git python3 ``` -------------------------------- ### Install Host Dependencies on CentOS Source: https://docs.craftycontrol.com/pages/getting-started/installation/linux?q= Installs necessary development tools, Python, and Java for Crafty on CentOS systems using dnf package manager. ```bash sudo dnf groupinstall "Development tools" && \ sudo dnf install python3 python3-devel java-1.8.0-openjdk java-1.8.0-openjdk-devel ``` -------------------------------- ### Start Crafty with Docker Compose (GitLab Registry) Source: https://docs.craftycontrol.com/pages/getting-started/installation/docker Starts the Crafty service defined in the docker-compose.yml file in detached mode and follows the logs. This is used after defining the service configuration. ```bash docker-compose up -d && docker-compose logs -f ``` -------------------------------- ### Update and Install Git on Debian/Ubuntu Source: https://docs.craftycontrol.com/pages/getting-started/installation/linux?q= Before installing Crafty, ensure your system's packages are up-to-date and Git is installed. This command is for Debian-based systems like Ubuntu. ```bash sudo apt update && sudo apt upgrade && sudo apt install git ``` -------------------------------- ### Install Modrinth Modpack (Linux) Source: https://docs.craftycontrol.com/pages/user-guide/faq?q= Use this command to install a Modrinth modpack using the 'mrpack-install' tool on Linux. Replace '' with the actual name of the modpack. ```bash ./mrpack-install-linux ``` -------------------------------- ### Install Modrinth Modpack on Windows Source: https://docs.craftycontrol.com/pages/user-guide/faq Command to install a Modrinth modpack using the mrpack-install tool on Windows. Replace '' with the actual modpack name. ```bash mrpack-install-windows.exe ``` -------------------------------- ### Install Crafty Dependencies Source: https://docs.craftycontrol.com/pages/getting-started/installation/macos?q= Installs all required Python packages for Crafty using pip. Reads dependencies from the 'requirements.txt' file. ```bash pip3 install --no-cache-dir -r requirements.txt ``` -------------------------------- ### Install Homebrew Package Manager Source: https://docs.craftycontrol.com/pages/getting-started/installation/macos?q= Installs the Homebrew package manager on macOS. This is a prerequisite for installing other development tools. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; ``` -------------------------------- ### Install Host Dependencies on Ubuntu/Debian Source: https://docs.craftycontrol.com/pages/getting-started/installation/linux?q= Installs essential packages required for Crafty on Ubuntu/Debian systems, including Git, Python development files, pip, and Java. ```bash sudo apt install git python3 python3-dev python3-pip software-properties-common openjdk-8-jdk openjdk-8-jre ``` -------------------------------- ### Get All Webhooks Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Retrieves a list of all configured webhooks. ```APIDOC ## GET /webhooks ### Description Retrieves a list of all configured webhooks. ### Method GET ### Endpoint /webhooks ### Parameters #### Query Parameters - **limit** (integer) - Optional - Limit the number of webhooks returned. - **offset** (integer) - Optional - Offset the list of webhooks returned. ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (array) - An array of webhook objects. - **webhook_id** (integer) - Example: 1 - **created** (string) - Example: 05/18/2022, 16:25:43 - **last_update** (string) - Example: 2022-05-18T16:25:45.377352 - **url** (string) - Example: https://example.com/webhook - **event** (string) - Example: server.start - **enabled** (boolean) - Example: true #### Response Example { "status": "ok", "data": [ { "webhook_id": 1, "created": "05/18/2022, 16:25:43", "last_update": "2022-05-18T16:25:45.377352", "url": "https://example.com/webhook", "event": "server.start", "enabled": true } ] } ``` -------------------------------- ### Create Crafty Directories Source: https://docs.craftycontrol.com/pages/getting-started/installation/macos?q= Creates the necessary directories for Crafty and Minecraft server files. Ensures a structured installation. ```bash sudo mkdir -p /var/opt/minecraft/crafty /var/opt/minecraft/server ``` -------------------------------- ### Make Modrinth Modpack Installer Executable on Linux Source: https://docs.craftycontrol.com/pages/user-guide/faq Grants execute permissions to the downloaded mrpack-install Linux binary. ```bash chmod +x ./mrpack-install-linux ``` -------------------------------- ### Download Modrinth Modpack Installer for Linux Source: https://docs.craftycontrol.com/pages/user-guide/faq Downloads the latest release of the mrpack-install tool for Linux. ```bash curl -LO https://github.com/nothub/mrpack-install/releases/latest/download/mrpack-install-linux ``` -------------------------------- ### Change Working Directory Source: https://docs.craftycontrol.com/pages/getting-started/installation/macos?q= Navigates to the newly created Crafty installation directory. Prepares for cloning the repository. ```bash cd /var/opt/minecraft/crafty ``` -------------------------------- ### Get All Servers Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Retrieves a list of all servers accessible by the authenticated user. Requires any valid user token. ```APIDOC ## GET /api/v2/servers ### Description Get all servers the user has access to. ### Method GET ### Endpoint /api/v2/servers ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (array) - List of servers ``` -------------------------------- ### Set Initial Admin Credentials Source: https://docs.craftycontrol.com/pages/getting-started/config?q= Create or rename the 'default.json' file (removing the '.example' extension) to define the admin username and password for unattended deployments. Ensure correct file permissions. ```json { "username": "admin", "password": "crafty" } ``` -------------------------------- ### Create Server Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Creates a new server instance. ```APIDOC ## POST /servers ### Description Creates a new server instance. ### Method POST ### Endpoint /servers ### Parameters #### Request Body - **server_name** (string) - Required - The name of the server. - **executable** (string) - Required - The executable file for the server (e.g., paper-1.18.2.jar). - **type** (string) - Required - The type of server (e.g., minecraft-java). - **path** (string) - Required - The path to the server directory. - **execution_command** (string) - Optional - The command to execute for starting the server. - **auto_start** (boolean) - Optional - Whether the server should auto-start. - **auto_start_delay** (integer) - Optional - Delay in seconds before auto-starting. - **crash_detection** (boolean) - Optional - Whether crash detection is enabled. - **stop_command** (string) - Optional - The command to stop the server. - **server_ip** (string) - Optional - The IP address for the server. - **server_port** (integer) - Optional - The port for the server. - **logs_delete_after** (integer) - Optional - How long to keep logs (0 for indefinite). ### Request Example { "server_name": "My New Server", "executable": "paper-1.18.2.jar", "type": "minecraft-java", "path": "/servers/my-new-server", "execution_command": "java -Xms1000M -Xmx2000M -jar paper-1.18.2.jar nogui", "auto_start": true, "auto_start_delay": 10, "crash_detection": true, "stop_command": "stop", "server_ip": "127.0.0.1", "server_port": 25565, "logs_delete_after": 0 } ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (object) - **new_server_id** (string) - The ID of the newly created server. #### Response Example { "status": "ok", "data": { "new_server_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef" } } ``` -------------------------------- ### Enable Crafty Service on Boot Source: https://docs.craftycontrol.com/pages/getting-started/installation/linux?q= Configure the Crafty service to start automatically when the system boots. This is useful for ensuring Crafty is always running. ```bash sudo systemctl enable crafty ``` -------------------------------- ### Create Server Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Creates a new server. Requires server creation permission. Supports creation of both Java and Bedrock edition servers. ```APIDOC ## POST /api/v2/servers ### Description Create a server. ### Method POST ### Endpoint /api/v2/servers ### Request Body - **(object)** - Required - Server creation details (either Java or Bedrock schema) ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (object) - **new_server_id** (string) - The ID of the newly created server. ``` -------------------------------- ### Download, Make Executable, and Ping Modrinth Modpack Tool (Linux) Source: https://docs.craftycontrol.com/pages/user-guide/faq?q= This single command line downloads the 'mrpack-install' tool for Linux, makes it executable, clears the screen, and then checks its connectivity to the Modrinth API. ```bash curl -LO https://github.com/nothub/mrpack-install/releases/latest/download/mrpack-install-linux && chmod +x mrpack-install-linux && clear && ./mrpack-install-linux ping ``` -------------------------------- ### Download and Install Modrinth Modpack on Linux Source: https://docs.craftycontrol.com/pages/user-guide/faq This command downloads the mrpack-install tool for Linux, makes it executable, and then pings the Modrinth API to check connectivity. ```bash curl -LO https://github.com/nothub/mrpack-install/releases/latest/download/mrpack-install-linux && chmod +x ./mrpack-install-linux && clear && ./mrpack-install-linux ping ``` -------------------------------- ### RuntimeError: can't start new thread with Docker Source: https://docs.craftycontrol.com/pages/user-guide/faq?q= This traceback indicates an issue with starting new threads, often seen with older Docker versions when running Crafty. No code action is provided as it's a Docker version issue. ```python Traceback ( File "/crafty/main.py", line 157, in controller = Controller(database, helper, file_helper, import_helper) File "/crafty/app/classes/shared/main_controller.py", line 78, in init self.support_scheduler.start() File "/.venv/lib/python3.10/site-packages/apscheduler/schedulers/background.py", line 38, in start self._thread.start() File "/usr/lib/python3.10/threading.py", line 935, in start _start_new_thread(self._bootstrap, ()) RuntimeError: can't start new thread ``` -------------------------------- ### Run Crafty Application Source: https://docs.craftycontrol.com/pages/getting-started/installation/macos?q= Starts the Crafty application by executing the main Python script. Ensure you are in the virtual environment and the correct directory. ```bash python3 main.py ``` -------------------------------- ### Get Announcements Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Retrieves announcements intended for the user. ```APIDOC ## GET /api/v2/crafty/announcements ### Description Fetches announcements that are displayed to the user. ### Method GET ### Endpoint /api/v2/crafty/announcements ### Response #### Success Response (200) - **status** (string) - Indicates the status of the operation, e.g., "ok". - **data** (array) - A list of announcements. - Each item in the array is an object conforming to the `Announcement` schema. #### Response Example { "status": "ok", "data": [ { "id": "dbc0c2aa-690a-46c3-aa67-db8e3bde0cd0", "message": "System maintenance scheduled for Sunday." } ] } #### Error Response (403) - Description: Failed authentication or invalid authentication. - Schema: Reference to `#/components/schemas/StatusError` ``` -------------------------------- ### Build Crafty Image Locally (Docker CLI) Source: https://docs.craftycontrol.com/pages/getting-started/installation/docker Fetches the latest code and builds a local Docker image for Crafty. Use this if you are not using a pre-built image. ```bash git fetch && git pull && docker build . -t crafty ``` -------------------------------- ### Get Task Status Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Retrieves the status of a specific task. ```APIDOC ## GET /tasks/{TaskID} ### Description Retrieves the status of a specific task. ### Method GET ### Endpoint /tasks/{TaskID} ### Parameters #### Path Parameters - **TaskID** (integer) - Required - Target Task ID. ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (object) - **task_id** (integer) - Example: 1 - **status** (string) - Example: completed - **created** (string) - Example: 2022-05-18T22:36:04.751211 - **completed** (string) - Example: 2022-05-18T22:36:05.751211 - **result** (string) - Example: Server started successfully. #### Response Example { "status": "ok", "data": { "task_id": 1, "status": "completed", "created": "2022-05-18T22:36:04.751211", "completed": "2022-05-18T22:36:05.751211", "result": "Server started successfully." } } ``` -------------------------------- ### Get Webhook by ID Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Retrieves a specific webhook by its ID. ```APIDOC ## GET /webhooks/{webhookID} ### Description Retrieves a specific webhook by its ID. ### Method GET ### Endpoint /webhooks/{webhookID} ### Parameters #### Path Parameters - **webhookID** (integer) - Required - Target webhook ID. ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (object) - **webhook_id** (integer) - Example: 1 - **created** (string) - Example: 05/18/2022, 16:25:43 - **last_update** (string) - Example: 2022-05-18T16:25:45.377352 - **url** (string) - Example: https://example.com/webhook - **event** (string) - Example: server.start - **enabled** (boolean) - Example: true #### Response Example { "status": "ok", "data": { "webhook_id": 1, "created": "05/18/2022, 16:25:43", "last_update": "2022-05-18T16:25:45.377352", "url": "https://example.com/webhook", "event": "server.start", "enabled": true } } ``` -------------------------------- ### Prepare API Token for Prometheus Source: https://docs.craftycontrol.com/pages/user-guide/open-metrics Create a secure directory and file to store the Crafty API token. Ensure proper permissions are set for security. ```bash sudo mkdir -p /etc/prometheus/secrets sudo chmod 700 /etc/prometheus/secrets sudo sh -c 'echo "YOUR_JWT_TOKEN_HERE" > /etc/prometheus/secrets/crafty_token' sudo chmod 600 /etc/prometheus/secrets/crafty_token ``` -------------------------------- ### Get User by ID Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Retrieves a specific user by their ID. ```APIDOC ## GET /users/{userID} ### Description Retrieves a specific user by their ID. ### Method GET ### Endpoint /users/{userID} ### Parameters #### Path Parameters - **userID** (integer) - Required - Target User ID. ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (object) - **user_id** (integer) - Example: 1 - **username** (string) - Example: testuser - **role_id** (integer) - Example: 1 - **created** (string) - Example: 05/18/2022, 16:25:43 - **last_login** (string) - Example: 2022-05-18T16:25:45.377352 - **mfa_enabled** (boolean) - Example: false #### Response Example { "status": "ok", "data": { "user_id": 1, "username": "testuser", "role_id": 1, "created": "05/18/2022, 16:25:43", "last_login": "2022-05-18T16:25:45.377352", "mfa_enabled": false } } ``` -------------------------------- ### Get All Users Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Retrieves a list of all users on the Crafty controller. ```APIDOC ## GET /users ### Description Retrieves a list of all users on the Crafty controller. ### Method GET ### Endpoint /users ### Parameters #### Query Parameters - **limit** (integer) - Optional - Limit the number of users returned. - **offset** (integer) - Optional - Offset the list of users returned. ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (array) - An array of user objects. - **user_id** (integer) - Example: 1 - **username** (string) - Example: testuser - **role_id** (integer) - Example: 1 - **created** (string) - Example: 05/18/2022, 16:25:43 - **last_login** (string) - Example: 2022-05-18T16:25:45.377352 - **mfa_enabled** (boolean) - Example: false #### Response Example { "status": "ok", "data": [ { "user_id": 1, "username": "testuser", "role_id": 1, "created": "05/18/2022, 16:25:43", "last_login": "2022-05-18T16:25:45.377352", "mfa_enabled": false } ] } ``` -------------------------------- ### Prepare API Token for Prometheus Source: https://docs.craftycontrol.com/pages/user-guide/open-metrics?q= Create a secure directory and store your JWT API token in a file for Prometheus to use. Ensure correct permissions are set for security. ```bash sudo mkdir -p /etc/prometheus/secrets sudo chmod 700 /etc/prometheus/secrets sudo sh -c 'echo "YOUR_JWT_TOKEN_HERE" > /etc/prometheus/secrets/crafty_token' sudo chmod 600 /etc/prometheus/secrets/crafty_token ``` -------------------------------- ### Download and Install Modrinth Modpack Tool for Linux Source: https://docs.craftycontrol.com/pages/user-guide/faq?q= This command downloads the 'mrpack-install' tool for Linux and makes it executable. It is used to prepare Modrinth modpacks outside of Crafty. ```bash curl -LO https://github.com/nothub/mrpack-install/releases/latest/download/mrpack-install-linux chmod +x ./mrpack-install-linux ``` -------------------------------- ### Get Server Metrics Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Retrieves Prometheus/OpenMetrics for a specific server. ```APIDOC ## GET /servers/{serverID}/metrics ### Description Retrieves Prometheus/OpenMetrics for a specific server. ### Method GET ### Endpoint /servers/{serverID}/metrics ### Parameters #### Path Parameters - **serverID** (string) - Required - Target server's ID. ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (string) - The metrics data in Prometheus text format. #### Response Example { "status": "ok", "data": "# HELP craft_server_cpu_usage CPU usage of the server process.\n# TYPE craft_server_cpu_usage gauge\ncraft_server_cpu_usage{server=\"5adcec83-684c-4555-a7e9-9d913203d07e\"} 15.5\n" } ``` -------------------------------- ### Get All Servers Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Retrieves a list of all servers managed by Crafty. ```APIDOC ## GET /servers ### Description Retrieves a list of all servers managed by Crafty. ### Method GET ### Endpoint /servers ### Parameters #### Query Parameters - **limit** (integer) - Optional - Limit the number of servers returned. - **offset** (integer) - Optional - Offset the list of servers returned. ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (array) - An array of server objects. - **server_id** (string) - Example: 5adcec83-684c-4555-a7e9-9d913203d07e - **created** (string) - Example: 2022-05-18T22:36:04.751211 - **server_uuid** (string) - Example: 5adcec83-684c-4555-a7e9-9d913203d07e - **server_name** (string) - Example: Example Server - **path** (string) - Example: /servers/e7e107ed-b4fd-4f87-b2dd-b66b4930706e - **backup_path** (string) - Example: /backups/e7e107ed-b4fd-4f87-b2dd-b66b4930706e - **executable** (string) - Example: paper-1.18.2.jar - **log_path** (string) - Example: /servers/e7e107ed-b4fd-4f87-b2dd-b66b4930706e/logs/latest.log - **execution_command** (string) - Example: java -Xms1000M -Xmx2000M -jar /servers/e7e107ed-b4fd-4f87-b2dd-b66b4930706e/paper-1.18.2.jar nogui - **auto_start** (boolean) - Example: false - **auto_start_delay** (integer) - Example: 10 - **crash_detection** (boolean) - Example: false - **stop_command** (string) - Example: stop - **executable_update_url** (string) - **server_ip** (string) - Example: 127.0.0.1 - **server_port** (integer) - Example: 25565 - **logs_delete_after** (integer) - Example: 0 - **type** (string) - Example: minecraft-java #### Response Example { "status": "ok", "data": [ { "server_id": "5adcec83-684c-4555-a7e9-9d913203d07e", "created": "2022-05-18T22:36:04.751211", "server_uuid": "5adcec83-684c-4555-a7e9-9d913203d07e", "server_name": "Example Server", "path": "/servers/e7e107ed-b4fd-4f87-b2dd-b66b4930706e", "backup_path": "/backups/e7e107ed-b4fd-4f87-b2dd-b66b4930706e", "executable": "paper-1.18.2.jar", "log_path": "/servers/e7e107ed-b4fd-4f87-b2dd-b66b4930706e/logs/latest.log", "execution_command": "java -Xms1000M -Xmx2000M -jar /servers/e7e107ed-b4fd-4f87-b2dd-b66b4930706e/paper-1.18.2.jar nogui", "auto_start": false, "auto_start_delay": 10, "crash_detection": false, "stop_command": "stop", "executable_update_url": null, "server_ip": "127.0.0.1", "server_port": 25565, "logs_delete_after": 0, "type": "minecraft-java" } ] } ``` -------------------------------- ### Get Role by ID Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Retrieves a specific role by its ID. ```APIDOC ## GET /roles/{role_id} ### Description Retrieves a specific role by its ID. ### Method GET ### Endpoint /roles/{role_id} ### Parameters #### Path Parameters - **role_id** (integer) - Required - The ID of the role to retrieve. ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (object) - **role_id** (integer) - Example: 1 - **created** (string) - Example: 05/18/2022, 16:25:43 - **last_update** (string) - Example: 2022-05-18T16:25:45.377352 - **role_name** (string) - Example: test 1234 - **manager** (integer) - Example: 1 - **mfa_required** (boolean) - Example: false #### Response Example { "status": "ok", "data": { "role_id": 1, "created": "05/18/2022, 16:25:43", "last_update": "2022-05-18T16:25:45.377352", "role_name": "test 1234", "manager": 1, "mfa_required": false } } ``` -------------------------------- ### Get Server by ID Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Retrieves details for a specific server by its ID. ```APIDOC ## GET /servers/{serverID} ### Description Retrieves details for a specific server by its ID. ### Method GET ### Endpoint /servers/{serverID} ### Parameters #### Path Parameters - **serverID** (string) - Required - Target server's ID. ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (object) - **server_id** (string) - Example: 5adcec83-684c-4555-a7e9-9d913203d07e - **created** (string) - Example: 2022-05-18T22:36:04.751211 - **server_uuid** (string) - Example: 5adcec83-684c-4555-a7e9-9d913203d07e - **server_name** (string) - Example: Example Server - **path** (string) - Example: /servers/e7e107ed-b4fd-4f87-b2dd-b66b4930706e - **backup_path** (string) - Example: /backups/e7e107ed-b4fd-4f87-b2dd-b66b4930706e - **executable** (string) - Example: paper-1.18.2.jar - **log_path** (string) - Example: /servers/e7e107ed-b4fd-4f87-b2dd-b66b4930706e/logs/latest.log - **execution_command** (string) - Example: java -Xms1000M -Xmx2000M -jar /servers/e7e107ed-b4fd-4f87-b2dd-b66b4930706e/paper-1.18.2.jar nogui - **auto_start** (boolean) - Example: false - **auto_start_delay** (integer) - Example: 10 - **crash_detection** (boolean) - Example: false - **stop_command** (string) - Example: stop - **executable_update_url** (string) - **server_ip** (string) - Example: 127.0.0.1 - **server_port** (integer) - Example: 25565 - **logs_delete_after** (integer) - Example: 0 - **type** (string) - Example: minecraft-java #### Response Example { "status": "ok", "data": { "server_id": "5adcec83-684c-4555-a7e9-9d913203d07e", "created": "2022-05-18T22:36:04.751211", "server_uuid": "5adcec83-684c-4555-a7e9-9d913203d07e", "server_name": "Example Server", "path": "/servers/e7e107ed-b4fd-4f87-b2dd-b66b4930706e", "backup_path": "/backups/e7e107ed-b4fd-4f87-b2dd-b66b4930706e", "executable": "paper-1.18.2.jar", "log_path": "/servers/e7e107ed-b4fd-4f87-b2dd-b66b4930706e/logs/latest.log", "execution_command": "java -Xms1000M -Xmx2000M -jar /servers/e7e107ed-b4fd-4f87-b2dd-b66b4930706e/paper-1.18.2.jar nogui", "auto_start": false, "auto_start_delay": 10, "crash_detection": false, "stop_command": "stop", "executable_update_url": null, "server_ip": "127.0.0.1", "server_port": 25565, "logs_delete_after": 0, "type": "minecraft-java" } } ``` -------------------------------- ### Get All Roles Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Retrieves a list of all available roles on the Crafty controller. ```APIDOC ## GET /roles ### Description Retrieves a list of all available roles on the Crafty controller. ### Method GET ### Endpoint /roles ### Parameters #### Query Parameters - **limit** (integer) - Optional - Limit the number of roles returned. - **offset** (integer) - Optional - Offset the list of roles returned. ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (array) - An array of role objects. - **role_id** (integer) - Example: 1 - **created** (string) - Example: 05/18/2022, 16:25:43 - **last_update** (string) - Example: 2022-05-18T16:25:45.377352 - **role_name** (string) - Example: test 1234 - **manager** (integer) - Example: 1 - **mfa_required** (boolean) - Example: false #### Response Example { "status": "ok", "data": [ { "role_id": 1, "created": "05/18/2022, 16:25:43", "last_update": "2022-05-18T16:25:45.377352", "role_name": "test 1234", "manager": 1, "mfa_required": false } ] } ``` -------------------------------- ### Initiate Password Reset Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Starts the password recovery process for a user account. ```APIDOC ## GET /api/v2/crafty/resetPass ### Description Initiates the password recovery system. This action does not require any specific permissions. ### Method GET ### Endpoint /api/v2/crafty/resetPass ### Response #### Success Response (200) - **status** (string) - Indicates the status of the operation, e.g., "ok". - **data** (string) - A message confirming the password reset procedure has started, e.g., "Lockout account has been activated for 1 hour. Please find temporary credentials in the terminal." #### Response Example { "status": "ok", "data": "Lockout account has been activated for 1 hour. Please find temporary credentials in the terminal." } #### Error Response (425) - Description: Request sent before the end of the previous anti-lockout period. - Schema: Contains `status` and `data` fields indicating the error, e.g., "Lockout recovery already in progress." ``` -------------------------------- ### Jinja2 Template for Server Start/Stop Events Source: https://docs.craftycontrol.com/pages/user-guide/webhooks?q= Use this Jinja2 template to create combined and descriptive messages for server start and stop events. It includes conditional logic based on the event type. ```jinja2 {% if event_type == "start_server" %} Server `{{ server_name }}` has started! {% elif event_type == "stop_server" %} Server `{{ server_name }}` has stopped. {% else %} Event: `{{ event_type }}` on server `{{ server_name }} {% endif %} Iso: `{{ time_iso }}` ``` -------------------------------- ### Get server webhook configuration Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Retrieves the webhook configuration for a specific server. ```APIDOC ## GET /api/v2/servers/{serverID}/webhook ### Description Get the webhook configuration for a server. ### Method GET ### Endpoint /api/v2/servers/{serverID}/webhook ### Parameters #### Path Parameters - **serverID** (string) - Required - The ID of the server. ``` -------------------------------- ### Create Webhook Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Creates a new webhook. ```APIDOC ## POST /webhooks ### Description Creates a new webhook. ### Method POST ### Endpoint /webhooks ### Parameters #### Request Body - **url** (string) - Required - The URL to send webhook events to. - **event** (string) - Required - The event to trigger the webhook (e.g., server.start, server.stop). - **enabled** (boolean) - Optional - Whether the webhook is enabled (defaults to true). ### Request Example { "url": "https://example.com/my-webhook", "event": "server.stop", "enabled": true } ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (object) - **webhook_id** (integer) - The ID of the newly created webhook. #### Response Example { "status": "ok", "data": { "webhook_id": 2 } } ``` -------------------------------- ### Get Authentication Token Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Obtains an authentication token (JWT) for API access. ```APIDOC ## POST /api/v1/security/token ### Description Obtains an authentication token (JWT) for API access. ### Method POST ### Endpoint /api/v1/security/token ### Parameters #### Request Body - **username** (string) - Required - The username for authentication. - **password** (string) - Required - The password for authentication. ### Request Example { "username": "apiuser", "password": "apisecret" } ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (object) - **token** (string) - The JWT authentication token. #### Response Example { "status": "ok", "data": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } } ``` -------------------------------- ### Build and Run Crafty locally using Docker CLI Source: https://docs.craftycontrol.com/pages/getting-started/installation/docker Builds a local Docker image named 'crafty-4' from the Dockerfile in the current directory, then runs it. This method is useful if you need to customize the build or use a local version. ```bash docker build . -t crafty-4 ``` ```bash docker run \ --name crafty_container \ --detach \ --restart always \ -p 8443:8443 \ -p 8123:8123 \ -p 19132:19132/udp \ -p 25500-25600:25500-25600 \ -e TZ=Etc/UTC \ -v "/$(pwd)/docker/backups:/crafty/backups" \ -v "/$(pwd)/docker/logs:/crafty/logs" \ -v "/$(pwd)/docker/servers:/crafty/servers" \ -v "/$(pwd)/docker/config:/crafty/app/config" \ -v "/$(pwd)/docker/import:/crafty/import" \ crafty-4 ``` -------------------------------- ### Get Server Console Logs Source: https://docs.craftycontrol.com/pages/developer-guide/api-reference/openapi-spec.yml Retrieves the console logs for a specific server. ```APIDOC ## GET /servers/{serverID}/logs ### Description Retrieves the console logs for a specific server. ### Method GET ### Endpoint /servers/{serverID}/logs ### Parameters #### Path Parameters - **serverID** (string) - Required - Target server's ID. #### Query Parameters - **lines** (integer) - Optional - Number of lines to retrieve from the end of the log file. ### Response #### Success Response (200) - **status** (string) - Example: ok - **data** (string) - The console log content. #### Response Example { "status": "ok", "data": "[Server log output...]" } ```