Environment:
- OPNsense Version: 25.4.3 Business
- API Documentation: https://docs.opnsense.org/development/api.html
- Python requests library with proper authentication
The firewall rule API endpoints exhibit two critical issues that prevent proper automation of firewall rule management.
Problem 1: searchrule API only returns enabled rules
Only enabled rules are returned. Disabled rules are completely omitted from the search results, even when using `"show_all": True` parameter.
Problem 2: toggle_rule API fails with "result": "failed"
The endpoint consistently returns {"result": "failed"} regardless of valid UUID and state parameters.
Additional Context:
- API key authentication works correctly for other endpoints
- UUIDs are valid and obtained from successful searchrule calls
- Similar issues reported in community forums without resolution
- Documentation examples do not work as described
Your help is appreciated :-)
- OPNsense Version: 25.4.3 Business
- API Documentation: https://docs.opnsense.org/development/api.html
- Python requests library with proper authentication
The firewall rule API endpoints exhibit two critical issues that prevent proper automation of firewall rule management.
Problem 1: searchrule API only returns enabled rules
Only enabled rules are returned. Disabled rules are completely omitted from the search results, even when using `"show_all": True` parameter.
Code Select
search_data = {
"current": 0,
"rowCount": 1000,
"sort": {},
"interface": "lan",
"show_all": True,
}
r = requests.post(
f"{remote_uri}/api/firewall/filter/searchrule",
auth=(api_key, api_secret),
json=search_data,
verify=certifi.where()
)
Problem 2: toggle_rule API fails with "result": "failed"
The endpoint consistently returns {"result": "failed"} regardless of valid UUID and state parameters.
Code Select
r = requests.post(
f"{remote_uri}/api/firewall/filter/toggle_rule/{valid_uuid}/0",
auth=(api_key, api_secret),
verify=certifi.where()
)
# Always returns: {"result": "failed"}
Additional Context:
- API key authentication works correctly for other endpoints
- UUIDs are valid and obtained from successful searchrule calls
- Similar issues reported in community forums without resolution
- Documentation examples do not work as described
Your help is appreciated :-)
"