Execute device action
POST /api/run/:device/:action
Execute a configured action on a specific device
Path parameters
The unique identifier of the device to control
The name of the action to execute (e.g.,
capture, set-mode, reboot)Request body
Optional parameters for the action. The schema is validated against the action’s configured parameter schema.Example for
set-mode action:Headers
Bearer token or use
X-API-Key header for API key authenticationMust be
application/json when sending parametersResponse
Indicates whether the action was executed successfully
The output from the executed command (present on success)
Error message describing what went wrong (present on failure)
Example: Execute action without parameters
Example: Execute action with parameters
Action execution flow
- Authentication - Validates user credentials and device access
- Device lookup - Retrieves device configuration from database
- Action lookup - Finds the action configuration by name
- Permission check - Verifies the action is configured for this device
- Parameter validation - Validates request body against action schema
- Command parsing - Parses the action command with provided parameters
- Execution - Runs command on device or locally based on target configuration
- Response - Returns execution output or error
Action targets
Actions can be configured to run in two different targets:- device - Command executes on the IoT device via SSH/network connection
- local - Command executes on the Joystick API server
Special actions
set-mode
Theset-mode action has special handling that updates the device’s mode field in the database after successful execution:
Error responses
404 Device not found
404 Action not found
404 Action not configured for device
400 Missing parameters
400 Invalid parameters
500 Execution failed
Logging and monitoring
All action executions are logged with the following information:- User ID and name
- Device ID and details
- Action name
- Parameters provided
- Execution duration
- Success/failure status
- Output or error message