System Config API (system.py
)
Prefix: /api/system/config
Tags: "System Config API"
Manages the dashboard's own configuration settings, stored in the .mesh-dash_config
file. Changes typically require a server restart to take full effect, which can be triggered via /api/system/restart
(main API) or handled by the /initial-setup
endpoint.
GET /
Reads and returns all key-value pairs from the .mesh-dash_config
file.
How it works: Reads the config file synchronously in a thread using read_dash_config
.
Response Body (application/json
): Dict[str, str]
representing the configuration.
{
"MESHTASTIC_HOST": "192.168.1.50",
"LOG_LEVEL": "INFO",
"SEND_LOCAL_NODE_LOCATION": "true"
}
Responses:
- 200 OK
- 404 Not Found: If the config file does not exist.
- 500 Internal Server Error: If there's an error reading the file.
Usage Example (cURL):
curl -X GET "http://localhost:8000/api/system/config/"
PUT /{key_name}
Updates the value of a specific key in the .mesh-dash_config
file. If the key does not exist, it will be added.
How it works: Reads the existing config, updates or adds the key, and rewrites the file synchronously in a thread using write_dash_config
. Preserves comments and formatting where possible.
Path Parameters:
Parameter | Type | Description |
---|---|---|
key_name | string | Required. The configuration key to update (e.g., MESHTASTIC_HOST ). |
Request Body (application/json
- Model: ConfigUpdateRequest
):
{ "value": "new_config_value" }
Response Body (application/json
): Dict[str, str]
showing the updated key-value pair.
{ "MESHTASTIC_HOST": "10.0.0.100" }
Responses:
- 200 OK
- 500 Internal Server Error: If there's an error writing the file.
Usage Example (cURL):
curl -X PUT "http://localhost:8000/api/system/config/MESHTASTIC_HOST" \
-H "Content-Type: application/json" \
-d '{"value": "10.0.0.100"}'
POST /initial-setup
Handles the initial setup data submission from the first-run wizard. Writes admin user credentials (INITIAL_ADMIN_USERNAME
, INITIAL_ADMIN_PASSWORD
) and selected privacy/community settings to the .mesh-dash_config
file. After successfully writing the configuration, it triggers an automatic server restart to apply changes and allow the main app to create the initial admin user from these config values.
How it works: Constructs a dictionary of configuration key-value pairs from the payload and writes them to the config file using write_dash_config
. If a static/.new
file exists (indicator for first setup), it's removed. Then, schedules a deferred task to restart the server via os.execv
.
Request Body (application/json
- Model: InitialSetupPayload
):
{
"adminUser": {
"username": "admin",
"password": "securepassword123"
},
"configValues": {
"SEND_LOCAL_NODE_LOCATION": "true",
"SEND_OTHER_NODES_LOCATION": "false",
"COMMUNITY_API": "true",
"LOCATION_OFFSET_ENABLED": "false",
"LOCATION_OFFSET_METERS": "0.0"
},
"rawSelections": {
"operatingMode": "private_network_operator",
"joinCommunity": "yes_anonymous",
"shareLocation": "yes",
"shareDetectedNodes": "no"
}
}
Responses:
- 200 OK: If the configuration is successfully written and restart is scheduled. Response:
{"message": "Initial setup data received...", "restart_scheduled": true}
. The client may not fully receive this if the restart is very fast. - 500 Internal Server Error: If there's an error writing the config file or if the restart command fails.
Note: This endpoint is typically used by the initial setup wizard and may not require prior authentication if the static/.new
file exists, allowing setup before login is possible.
POST /request-restart
This endpoint is informational. It acknowledges that a manual server restart is needed for certain configuration changes to take full effect (e.g., changes made via direct file edit or other non-restarting API calls). It does not programmatically restart the server.
How it works: Simply returns a message advising the user to restart the service.
Request Body: None.
Response Body (application/json
):
{
"message": "Acknowledgement: For all recent configuration changes to be fully applied, please restart the MeshDash service..."
}
Responses:
- 200 OK
Usage Example (cURL):
curl -X POST "http://localhost:8000/api/system/config/request-restart"