Device rules

After 2026-10-R1, device rules tag, color, sort, and collect devices into views, and raise alerts, on the server.

Devices which match at least one rule carry kismet.device.base.rules:

FieldContent
kismet.device.rules.matchedNames of the rules the device matches
kismet.device.rules.tagsTags from the matching rules
kismet.device.rules.colorHighlight color from the first matching rule with a color

Each rule with a view makes a device view named rule-<name>, and device views can be ordered with a sort by passing rule_sort.

Rules set over the API come after the rules from the Kismet config, and replace only the rules set earlier over the API.

Device rules

DESC

The device rules and sorts currently loaded, in order, and how they are evaluated.

FieldContent
kismet.devicerules.backendjit when rules are compiled to native code, vm when they run in the bytecode interpreter, or none
kismet.devicerules.jit_errorWhy the rules aren’t using the JIT, when they aren’t
kismet.devicerules.rulesThe rules: kismet.devicerules.rule.name, .source (the rule text), .tags, .color, .view (the rule-<name> view, when the rule has one), .alert, .live, and .origin (the file and line the rule came from)
kismet.devicerules.sortsThe sorts: kismet.devicerules.sort.name, .source, and .origin
kismet.devicerules.api_rulesThe rules text last set with set.cmd
kismet.devicerules.api_saveRules set with set.cmd are saved and loaded at startup (device_rules_api_save)
kismet.devicerules.passesRule checks run so far
kismet.devicerules.evaluatedDevices checked by those passes
kismet.devicerules.last_pass_usDuration of the last pass, in microseconds
ROLES
readonly
ADDED
API added after 2026-10-R1
URI
/devices/rules/rules.json
/devices/rules/rules.ekjson
/devices/rules/rules.prettyjson
METHODS
GET POST
JSON
PARAMETERS

This endpoint takes additional parameters by using a `POST` request and supplying a JSON document or json form variable.

You can find more information about API parameters here.

fields field simplification OPTIONAL

Kismet can reduce the amount of information being processed and returned by an API by simplifying the fields to only return the data needed by the caller.

You can read more about the field simplification API and how to use it here.

RETURN
Dictionary of the rules and sorts
RESPONSES
200
Success

Check rules

DESC
Check rules without loading them. The rules are checked as set.cmd would load them: after the configured rules, replacing the rules set earlier over the API.
ROLES
admin
ADDED
API added after 2026-10-R1
URI
/devices/rules/check.cmd
METHODS
POST
JSON
PARAMETERS

This endpoint takes additional parameters by using a `POST` request and supplying a JSON document or json form variable.

You can find more information about API parameters here.

rules string REQUIRED

Rules and sorts, in the device rules language; at most 256KB. Rules set over the API can’t include other files.

RETURN

On success, {"ok": true, "backend": "jit" or "vm", "rules": [names], "sorts": [names], "replaced": [...]}, where replaced lists configured rules and sorts which these rules replace by name.

On an error in the rules, {"ok": false, "error": "...", "line": N, "col": N}.

RESPONSES
200
Rules checked; see `ok`
400
Missing or too large `rules`

Set rules

DESC

Replace the rules set over the API. They come after the rules from the Kismet config and replace only the rules set earlier over the API; a rule with the same name as a configured rule replaces it.

If any rule has an error, nothing changes. When device_rules_api_save=true, the rules are written to device_rules_api_file and loaded again at startup. Rules which would make more than 256 views in all are an error.

Devices are checked against the new rules on the next pass, and join or leave rule views and raise alerts as they start or stop matching.

ROLES
admin
ADDED
API added after 2026-10-R1
URI
/devices/rules/set.cmd
METHODS
POST
JSON
PARAMETERS

This endpoint takes additional parameters by using a `POST` request and supplying a JSON document or json form variable.

You can find more information about API parameters here.

rules string REQUIRED

Rules and sorts, in the device rules language; at most 256KB. An empty string removes the rules set over the API.

RETURN

On success, {"ok": true, "rules": N, "sorts": N, "backend": "jit" or "vm", "replaced": [...], "saved": true or false}, with save_error when saving the rules failed.

On an error in the rules, {"ok": false, "error": "...", "line": N, "col": N}.

RESPONSES
200
Rules set, or an error in the rules; see `ok`
400
Missing or too large `rules`

Test rules on a device

DESC
Test which of the given rules match a device, without loading them.
ROLES
admin
ADDED
API added after 2026-10-R1
URI
/devices/rules/test.cmd
METHODS
POST
JSON
PARAMETERS

This endpoint takes additional parameters by using a `POST` request and supplying a JSON document or json form variable.

You can find more information about API parameters here.

rules string REQUIRED

Rules to test, in the device rules language. Only these rules are tested, without the configured rules.

device string REQUIRED

Device key

RETURN

On success, {"ok": true, "matches": {"rule name": true or false, ...}}.

On an error in the rules, {"ok": false, "error": "...", "line": N, "col": N}.

RESPONSES
200
Rules tested; see `ok`
400
Missing parameters or an invalid device key
404
No such device