Skip to content

toggle_traffic_rule

Enable or disable a traffic rule without editing its other fields.

Side effects:

  • Flips the rule’s enabled flag. Reads the current rule first and PUTs the full object back with only enabled changed (read-modify-write), so the rest of the rule is preserved.
  • Takes effect immediately: a disabled BLOCK rule stops blocking; a disabled ALLOW rule stops allowing.
  • Mutates controller state. Use dry_run=True to preview the change without applying.
toggle_traffic_rule(rule_id="65f...", enabled=False)
ParameterTypeRequiredDefaultDescription
rule_idstringyesThe _id from list_traffic_rules.
enabledbooleanyesTrue to enable the rule, False to disable it.
controllerstringno”default”Name of the UniFi controller to target. Defaults to "default".
dry_runbooleannofalsePreview the change without applying it. Returns the predicted change set.