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
kismet.device.rules.excludedSet when an exclude rule matches the device, which leaves it out of the default view (after 2026-10-R1)

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.

After 2026-10-R1, devices which no exclude rule matches make up the device view default.

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, .description, .source (the rule text), .tags, .color, .view (the rule-<name> view, when the rule has one), .alert, .live, .origin (the file and line the rule came from), and, after 2026-10-R1, .from_type and .from_name (what defined the rule, as in sources), .exclude (the rule leaves matching devices out of the default view), .enabled (false when the rule is switched off), .matching (how many devices matched the rule when last checked), and .recheck (seconds between checks of unchanged devices, for rules whose conditions change over time; 0 for other rules)
Baseline filtersAfter 2026-10-R1, baseline filters are listed with the rules, with .baseline (add or remove), .every (seconds between runs), .ephemeral, .expire (seconds, 0 for none), .baseline_active (false when device_rules_baseline is off), and what their runs have done: .last_run (time), .runs, .added, .removed, .expired, .held (devices held out of the baseline), and .over_limit (matches left for a later run by device_rules_baseline_max_changes). Their .matching is always 0
kismet.devicerules.sortsThe sorts: kismet.devicerules.sort.name, .source, .origin, and, after 2026-10-R1, .from_type and .from_name
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

Device rules by source

DESC

The device rules and sorts currently loaded, grouped by what defined them, as the web UI’s Device rules window shows them.

kismet.devicerules.sources is a list of groups, in the order their first rule or sort comes in:

FieldContent
kismet.devicerules.source.typefile (a rules file or directory), config (device_rule= and device_sort= lines), plugin, or api
kismet.devicerules.source.nameThe rules file, the config file, the plugin name, or API
kismet.devicerules.source.filesThe files the group’s rules and sorts came from
kismet.devicerules.source.rulesThe group’s rules, in rule order, as in rules.json
kismet.devicerules.source.sortsThe group’s sorts, as in rules.json
kismet.devicerules.source.replacedNotes on earlier rules and sorts of the same name which this group replaced
ROLES
readonly
ADDED
API added after 2026-10-R1
URI
/devices/rules/sources.json
/devices/rules/sources.ekjson
/devices/rules/sources.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 by source
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, sorts, and (after 2026-10-R1) baseline filters, 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`

Switch a rule off or on

DESC

Switch a loaded rule off or back on. A rule that’s off isn’t checked, and its tags, color, view, alerts, and webhooks go with it; it’s still listed, with kismet.devicerules.rule.enabled false.

Rules switched off are saved to device_rules_disabled_file and stay off across restarts, and after the rule set is replaced.

ROLES
admin
ADDED
API added after 2026-10-R1
URI
/devices/rules/enable.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.

rule string REQUIRED

Rule name

enabled boolean REQUIRED

false to switch the rule off, true to switch it back on

RETURN
On success, {"ok": true, "rule": "name", "enabled": true or false, "saved": true or false}, with save_error when saving the list of rules switched off failed.
RESPONSES
200
Rule switched off or on
400
Missing parameters, or no such rule; `{"ok": false, "error": "..."}`

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