Skip to content

create_vlan

Create a VLAN-tagged network on the controller.

Side effects:

  • Adds a new network record with the given VLAN ID, IP subnet, and DHCP scope. The first usable address (.1) becomes the gateway.
  • Mutates controller state. Use dry_run=True to preview the change without applying.
create_vlan(name="iot", vlan_id=50, subnet="10.50.0.0/24")
ParameterTypeRequiredDefaultDescription
namestringyesNetwork display name (e.g. "iot", "cameras").
vlan_idintegeryes802.1Q VLAN ID, 2-4094.
subnetstringyesSubnet in either gateway-IP form ("10.50.0.1/24", what the UniFi controller stores) or network form ("10.50.0.0/24"). Network form is auto-promoted to gateway form before the POST so callers don’t have to remember which one UniFi wants. /24 only.
dhcp_startstringno""First DHCP lease address. Empty = derived from IOT_DHCP_START_OFFSET.
dhcp_stopstringno""Last DHCP lease address. Empty = derived from IOT_DHCP_STOP_OFFSET.
purposestringno”corporate”"corporate" for normal LANs, "guest" for hotspot-style isolation.
controllerstringno”default”Name of the UniFi controller to target. Defaults to "default".
dry_runbooleannofalsePreview the change without applying it. Returns the predicted change set.