Smart blaze REST API Reference#
The REST API can be used to control of the virtual machine (VM). It allows you to manage the VM lifecycle, upload images, and configure network settings from the command line or using custom scripts.
All API endpoints are accessed via the camera's IP address:
Info
Replace ${cameraip} with your camera's actual IP address.
Authentication#
The Smart blaze REST API uses session-based authentication with a challenge-response mechanism to protect against unauthorized access. The default password is unique for each camera and printed on a label on the camera.
All API endpoints (except /login) require authentication via session cookies. Authentication involves three steps:
- Obtaining a login challenge by sending a GET request to
/login - Computing the challenge response using the nonce from the challenge
- Submitting the challenge response to complete authentication
Obtaining a Login Challenge#
Endpoint: /login
Method: GET
Response: HTML page containing a nonce in a hidden form field
Computing the Challenge Response#
The challenge response must be computed as follows:
Where:
nonceis the value from the login challenge.passwordis your plain-text password.- SHA256 produces a lowercase hexadecimal string.
Example (using the shell):
# Get the nonce from the login page
NONCE=$(curl -s http://${cameraip}/login | grep -oP 'id="challenge-nonce"[^>]*value="\K[^"]+')
# Your password
PASSWORD="blaze-oh-yeah"
# Compute password hash
PASSWORD_HASH=$(echo -n "$PASSWORD" | sha256sum | awk '{print $1}')
# Compute challenge response
RESPONSE=$(echo -n "${NONCE}:${PASSWORD_HASH}" | sha256sum | awk '{print $1}')
Submitting the Challenge Response#
Endpoint: /login
Method: POST
Content-Type: application/x-www-form-urlencoded
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
challenge_response | String | Yes | The computed challenge response (SHA256 hex string) |
Response: Redirects to main page on success. Returns login page with error on failure.
Example:
curl -c cookies.txt -b cookies.txt -X POST http://${cameraip}/login \
-d "challenge_response=${RESPONSE}"
After successful authentication, include the session cookie in all subsequent API requests:
Complete Authentication Example#
Here's a complete shell script example:
#!/bin/bash
CAMERA_IP="192.168.1.123"
PASSWORD="blaze-oh-yeah"
# Get login challenge
echo "Getting login challenge..."
NONCE=$(curl -s -c cookies.txt http://${CAMERA_IP}/login | \
grep -oP 'id="challenge-nonce"[^>]*value="\K[^"]+')
if [ -z "$NONCE" ]; then
echo "Failed to get login challenge"
exit 1
fi
# Compute challenge response
PASSWORD_HASH=$(echo -n "$PASSWORD" | sha256sum | awk '{print $1}')
RESPONSE=$(echo -n "${NONCE}:${PASSWORD_HASH}" | sha256sum | awk '{print $1}')
# Login
echo "Logging in..."
curl -s -b cookies.txt -c cookies.txt -X POST http://${CAMERA_IP}/login \
-d "challenge_response=${RESPONSE}" > /dev/null
# Now you can make authenticated API calls
echo "Making authenticated API call..."
curl -b cookies.txt -X POST http://${CAMERA_IP}/vm/restart
echo "Done"
Security Features#
- Challenge-Response Authentication: Prevents password transmission over the network.
- Rate Limiting: Failed login attempts are rate-limited to prevent brute-force attacks.
- Session Security:
- HTTP-only cookies (not accessible via JavaScript)
- SameSite=Strict cookie policy
- 60-second challenge timeout
- Password Storage: Passwords are stored as SHA256 hashes only.
Users can set a custom password via the web interface.
Session Logout#
To log out and clear the session:
Endpoint: /logout
Method: POST
API Endpoints#
Info
All endpoints listed below require authentication. You must first authenticate using the /login endpoint and include the session cookie in your requests. See the Authentication section for details.
For brevity, the examples below show the API calls without the authentication step. In practice, include -b cookies.txt in your curl commands after authenticating.
API Calls for VM Control#
Restarting the VM#
Restart the virtual machine.
Endpoint: /vm/restart
Method: POST
Response: Redirects to main page
Example:
Starting the VM#
Start the virtual machine.
Endpoint: /vm/start
Method: POST
Response: Redirects to main page
Example:
Stopping the VM#
Stop the virtual machine.
Endpoint: /vm/stop
Method: POST
Response: Redirects to main page
Example:
API Calls for VM Configuration#
Configuring IP Settings#
Configure the VM's network settings (DHCP or static IP).
Endpoint: /vm/ip
Method: POST
Content-Type: application/x-www-form-urlencoded
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
mode | String | Yes | Network mode: "DHCP" or "Manual" |
address | String | Conditional | IP address with CIDR notation (e.g., "192.168.1.127/24"). Required when mode is "Manual". |
gateway | String | No | Gateway IP address (e.g., "192.168.1.1"). Leave empty to omit. |
dns0 | String | No | Primary DNS server address (e.g., "8.8.8.8"). Leave empty to omit. |
dns1 | String | No | Secondary DNS server address. Leave empty to omit. |
Response: Redirects to main page
Info
This endpoint temporarily stops the VM to apply the network configuration changes.
Example: Configuring Static IP#
curl -X POST http://${cameraip}/vm/ip \
-d "mode=Manual" \
-d "address=192.168.1.127/24" \
-d "gateway=192.168.1.1" \
-d "dns0=8.8.8.8" \
-d "dns1=8.8.4.4"
Example: Enabling DHCP#
curl -X POST http://${cameraip}/vm/ip \
-d "mode=DHCP" \
-d "address=192.168.1.127/24" \
-d "gateway=" \
-d "dns0=" \
-d "dns1="
Updating VM Settings#
Configure VM behavior settings.
Endpoint: /vm/settings
Method: POST
Content-Type: application/x-www-form-urlencoded
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
wait_console | String | No | Enable console wait mode: "on" or "true". Omit or use any other value to disable. |
Response: Redirects to main page
Example:
Image Management#
Listing Available Images#
List all installed VM images with their active status and size.
Endpoint: /vm/images
Method: GET
Response: JSON array of image objects
Response Fields:
| Field | Type | Description |
|---|---|---|
name | String | Name of the image |
is_active | Boolean | Indicates whether this image is currently active. |
size | String | Disk size of the image (human-readable, e.g., "1.2G") |
Example:
Response:
[
{"name": "debian-arm64-min", "is_active": true, "size": "1.2G"},
{"name": "custom-app", "is_active": false, "size": "2.4G"}
]
Checking VM Image Upload#
Check whether a VM image can be uploaded before transferring the archive. This validates the file name, .tar.gz extension, image name, overwrite constraints, and available storage space using the same checks as the upload endpoint.
Endpoint: /vm/check_image_uploadable
Method: POST
Content-Type: application/json
Request Fields:
| Field | Type | Required | Description |
|---|---|---|---|
filename | String | Yes | Name of the archive, including the .tar.gz extension |
size | Integer | Yes | Archive size in bytes |
overwrite | Boolean | No | Allows replacing an existing inactive image. Default: false |
Success Response:
If an inactive image with the same name exists and overwrite is false:
{
"success": false,
"error": "Image 'debian-arm64-8GB' already exists.",
"needs_confirmation": true
}
Other validation failures return:
Example:
curl -X POST http://${cameraip}/vm/check_image_uploadable \
-H "Content-Type: application/json" \
-d '{"filename":"debian-arm64-8GB.tar.gz","size":2147483648,"overwrite":false}'
Info
A successful check doesn't reserve the image name or storage space. The upload endpoint repeats these checks. Archive contents and file types can only be validated after the archive has been uploaded.
Uploading VM Image#
Upload a new VM image archive. The archive should contain the rootfs and kernel files.
Endpoint: /vm/image
Method: POST
Content-Type: multipart/form-data
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
file | File | Yes | VM image archive (.tar.gz format) |
overwrite | Query | No | Set to "true" to overwrite an existing image with the same name. Default: "false" |
set_active | Query | No | Set to "true" to activate the uploaded image immediately (VM will restart). Set to "false" to upload without activating. Default: "true" |
Supported Archive Contents:
The uploaded archive must contain the following:
- A rootfs file:
rootfs.qcow2,rootfs.img, orrootfs.raw - A kernel file:
kernel
For more information, see VM Image Structure.
Response: JSON
Success Response:
Error Responses:
Info
When set_active=true (default), this endpoint temporarily stops the VM during the upload and activation process. When set_active=false, the image is only uploaded and stored without affecting the running VM.
Example: Uploading and Activating New Image (Default)#
Response:
Example: Uploading Without Activating#
Response:
Example: Upload Failed (Image Exists)#
Response:
Example: Overwriting Existing Image and Activating#
Example: Overwriting Existing Image Without Activating#
curl -F "file=@debian-arm64-8GB.tar.gz" "http://${cameraip}/vm/image?overwrite=true&set_active=false"
Selecting the Active Image#
Change the active VM image to a different installed image.
Endpoint: /vm/select_image
Method: POST
Content-Type: application/x-www-form-urlencoded
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
image_name | String | Yes | Name of the image to activate |
Response: Redirects to main page
Info
This endpoint temporarily stops the VM to switch the active image.
Example:
Deleting a VM Image#
Delete an installed VM image.
Endpoint: /vm/delete_image
Method: POST
Content-Type: application/x-www-form-urlencoded
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
image_name | String | Yes | Name of the image to delete |
Response: Redirects to main page
Info
You can't delete the image that is currently active. Select a different image first.
Example:
Renaming a VM Image#
Rename an installed VM image.
Endpoint: /vm/rename_image
Method: POST
Content-Type: application/x-www-form-urlencoded
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
old_image_name | String | Yes | Current name of the image |
new_image_name | String | Yes | New name of the image |
Response: Redirects to main page
Info
If you're renaming the active image, this endpoint temporarily stops the VM.
Example:
curl -X POST http://${cameraip}/vm/rename_image \
-d "old_image_name=debian-arm64-8GB" \
-d "new_image_name=my-custom-vm"
System Maintenance#
Factory Reset#
Reset the VM to factory defaults. This removes all custom VM images, restores the original rootfs and kernel, and resets the VM configuration.
Endpoint: /vm/factory_reset
Method: POST
Response: JSON
Success Response:
Error Response:
Info
This endpoint temporarily stops the VM and deletes all user data. Use with caution!
Example:
Response:
Error Handling#
API endpoints that return JSON include a success field:
true: Operation completed successfully.false: Operation failed. Check theerrorfield for details.
Some error responses may include additional fields:
needs_confirmation: Set totrueif the operation requires explicit confirmation (e.g., overwriting an existing image).
Common Use Cases#
Uploading and Activating a Custom VM Image#
#!/bin/bash
CAMERA_IP="192.168.1.123"
PASSWORD="blaze-oh-yeah" # Replace with your camera's password
IMAGE_FILE="my-custom-vm.tar.gz"
# Authenticate
NONCE=$(curl -s -c cookies.txt http://${CAMERA_IP}/login | \
grep -oP 'id="challenge-nonce"[^>]*value="\K[^"]+')
PASSWORD_HASH=$(echo -n "$PASSWORD" | sha256sum | awk '{print $1}')
RESPONSE=$(echo -n "${NONCE}:${PASSWORD_HASH}" | sha256sum | awk '{print $1}')
curl -s -b cookies.txt -c cookies.txt -X POST http://${CAMERA_IP}/login \
-d "challenge_response=${RESPONSE}" > /dev/null
# Upload and activate the image archive (default behavior)
RESULT=$(curl -b cookies.txt -F "file=@${IMAGE_FILE}" http://${CAMERA_IP}/vm/image)
echo "$RESULT"
# The VM will automatically restart with the new image
Uploading VM Image Without Activating It#
#!/bin/bash
CAMERA_IP="192.168.1.123"
PASSWORD="blaze-oh-yeah" # Replace with your camera's password
IMAGE_FILE="backup-vm.tar.gz"
# Authenticate (authentication code omitted for brevity, see above)
# Upload the image without activating it (VM keeps running)
RESULT=$(curl -b cookies.txt -F "file=@${IMAGE_FILE}" \
"http://${CAMERA_IP}/vm/image?set_active=false")
echo "$RESULT"
# The image is now stored but not active. You can activate it later using /vm/select_image
Switching Between Installed Images#
# Authenticate (see above for full authentication example)
# Then select a different image
curl -b cookies.txt -X POST http://${cameraip}/vm/select_image \
-d "image_name=debian-arm64-base"
Configuring Static IP for Direct Connection#
# Authenticate first, then configure network
curl -b cookies.txt -X POST http://${cameraip}/vm/ip \
-d "mode=Manual" \
-d "address=192.168.1.200/24" \
-d "gateway=192.168.1.1" \
-d "dns0=8.8.8.8" \
-d "dns1="
Automating VM Image Deployment#
#!/bin/bash
CAMERA_IP="192.168.1.123"
PASSWORD="blaze-oh-yeah" # Replace with your camera's password
IMAGE_FILE="production-vm.tar.gz"
# Function to authenticate
authenticate() {
echo "Authenticating..."
NONCE=$(curl -s -c cookies.txt http://${CAMERA_IP}/login | \
grep -oP 'id="challenge-nonce"[^>]*value="\K[^"]+')
if [ -z "$NONCE" ]; then
echo "Failed to get login challenge"
return 1
fi
PASSWORD_HASH=$(echo -n "$PASSWORD" | sha256sum | awk '{print $1}')
RESPONSE=$(echo -n "${NONCE}:${PASSWORD_HASH}" | sha256sum | awk '{print $1}')
curl -s -b cookies.txt -c cookies.txt -X POST http://${CAMERA_IP}/login \
-d "challenge_response=${RESPONSE}" > /dev/null
return 0
}
# Authenticate
if ! authenticate; then
echo "Authentication failed"
exit 1
fi
# Upload VM image without activating it
echo "Uploading VM image to camera..."
RESPONSE=$(curl -s -b cookies.txt -F "file=@${IMAGE_FILE}" \
"http://${CAMERA_IP}/vm/image?set_active=false")
if echo "$RESPONSE" | grep -q '"success":true'; then
echo "Upload successful!"
else
echo "Upload failed:"
echo "$RESPONSE"
exit 1
fi
# Activate the uploaded image
echo "Activating new VM image..."
IMAGE_NAME="${IMAGE_FILE%.tar.gz}"
curl -s -b cookies.txt -X POST http://${CAMERA_IP}/vm/select_image \
-d "image_name=${IMAGE_NAME}"
echo "VM is restarting with new image."
Info
This script can be run from any system with network access to the camera, including from within the VM itself. When run from the VM, the script uploads a new image and the VM will restart with the new image after activation. This allows for self-updating VMs.
VM Control Web Interface#
For interactive management, access the Smart blaze VM Control web interface:
The web interface provides a graphical user interface for the following tasks:
- Viewing the VM status
- Controlling the VM lifecycle (start/stop/restart)
- Configuring network settings
- Uploading and managing VM images
- Monitoring disk usage
- Changing the password
Info
The web interface uses the same authentication mechanism as the REST API.
Further Information#
- For information about initial setup and configuration, see Getting Started.