Trigger: HTTP Server Request
The HTTP Server Request trigger creates a local HTTP server on your device that can trigger macros based on specific HTTP requests. This allows external devices on the same local network to trigger macros by sending HTTP requests to your device.
Options
- Identifier: A unique path identifier for this trigger. The full URL will be: http://[device_ip]:[port]/[identifier]. Supports magic text.
- IP Address Whitelist: Restrict which IP addresses can trigger this macro. Multiple entries can be added. Supports wildcards and magic text. Leave empty to allow all IP addresses.
- Variable Whitelist: When configured, only the specified variables can be updated via the HTTP request parameters. Variables not in the whitelist will be blocked with a warning logged.
- Send Response: When enabled, the trigger sends a response to the HTTP client.
- Response Text: The text content to send in the response. Supports magic text.
- Response Code: The HTTP status code to return (e.g., 200 OK, 404 Not Found, etc.)
- Header Parameters: Additional HTTP headers to include in the response.
- Save Body to Variable: Store the HTTP request body content into a string variable, optionally with dictionary keys for structured data.
- Save Body to File: Save the HTTP request body to a file.
- Directory: The directory path where the file will be saved. Supports magic text.
- Filename: The filename to use. Supports magic text.
HTTP Server Settings
The HTTP server port can be configured in MacroDroid Settings. Click the "HTTP Server Settings" link in the trigger configuration to access these settings.
Examples
Example 1: Simple Macro Trigger
Triggers HTTP Server Request - toggle_flashlight
Actions Torch Toggle
Toggles the flashlight when an HTTP request is made to: http://192.168.1.100:8080/toggle_flashlight
Example 2: Update Variable via HTTP
Triggers HTTP Server Request - set_status
Actions Popup Message - Status updated to: [v=status]
Updates a variable by making a request like: http://192.168.1.100:8080/set_status?status=active
Magic Text
When this trigger fires, the following magic text values are available:
- Request IP address - {http_caller_ip}
- Query parameters string - {http_query_string}
- HTTP headers - {http_request_headers}
Notes
- The HTTP server only operates on the local network - it is not accessible from the internet.
- The device's IP address may change (e.g., when reconnecting to WiFi). Consider using a static IP assignment on your router for consistent access.
- Use the IP whitelist feature to restrict access to trusted devices for security.
- The variable whitelist feature prevents unauthorized variable modifications when variables are passed via URL parameters.
- Multiple triggers can share the same HTTP server (running on the same port) with different identifiers.
- The server supports GET and POST requests.
- Body content from POST requests can be saved to a variable or file.
- On Android 11+, saving body to file requires "All Files Access" permission.
URL Parameter Format
To set variables via URL parameters, use the format:
http://[ip]:[port]/[identifier]?variable_name=value&another_var=value2
See Also