create_traffic_rule
Create a UniFi traffic rule to block, throttle, or route by application/IP group. Specify action, matching target, and target devices for QoS or security policies.
Instructions
Create a traffic matching rule (QoS, block, or route by application/IP group).
host: console name, ID, or composite ID (MAC:numericId format). site: site name or ID. payload: required fields (validated locally — a missing field raises ValueError naming it — and verified against the live controller):
action: 'BLOCK'|'THROTTLE_RATE'|'QUEUE'
matching_target: 'INTERNET'|'LOCAL'|'ALL' or a traffic matching list ID
target_devices: the devices/networks the rule applies to (required by the API; previously undocumented) Optional (NOT required by the API): description (str), enabled (bool, controller defaults it), matching_target_type ('INTERNET'|'DOMAIN'|'IP_GROUP'|'APPLICATION_GROUP'), bandwidth_limit (dict with up_limit_kbps/down_limit_kbps for THROTTLE_RATE). Note: uses the Classic REST v2 API (/v2/api/site/{siteId}/trafficrules). May not exist on firmware 10.2.105 and below.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | Yes | ||
| site | Yes | ||
| payload | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||