Required MAC address of the device to move
Required Target site ID to move the device to
Current site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if device move was successful
When MAC address or site_id is invalid
When device move fails
// Move device to different site
await networkAPI.move_device('aa:bb:cc:dd:ee:ff', 'branch-office');
// Move multiple devices (call multiple times)
const devicesToMove = ['aa:bb:cc:dd:ee:ff', 'ff:ee:dd:cc:bb:aa'];
for (const mac of devicesToMove) {
await networkAPI.move_device(mac, 'new-site');
}
Moving a device will cause it to be reconfigured for the target site
PHP: move_device($mac, $site_id) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/cmd/sitemgr', $payload);
Protected substituteProtected makeCreate a new WLAN (Wireless Network) configuration
Required Name of the WLAN (SSID)
Required Network password/passphrase (ignored for open networks)
Required ID of the user group to assign clients to
Required ID of the WLAN group for AP assignment
Optional whether the WLAN is enabled (default: true)
Optional whether to hide the SSID (default: false)
Optional whether this is a guest network (default: false)
Optional security type: 'open', 'wpapsk', 'wpaeap' (default: 'open')
Optional WPA mode: 'wpa', 'wpa2', 'wpa3' (default: 'wpa2')
Optional WPA encryption: 'auto', 'ccmp', 'tkip' (default: 'ccmp')
Optional vlan_enabled: booleanOptional whether VLAN is enabled
Optional vlan_id: stringOptional VLAN network ID
Optional whether U-APSD is enabled (default: false)
Optional whether scheduling is enabled (default: false)
Optional schedule configuration array (default: [])
Optional ap_group_ids: string[]Optional array of AP group IDs to restrict WLAN to
Optional additional configuration parameters
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal for request cancellation
Promise resolving to true if WLAN creation was successful
Creates a new wireless network with specified security settings, user groups, and advanced configuration options. The WLAN will be available on all Access Points unless restricted to specific AP groups.
When required parameters are missing or invalid
When WLAN creation fails or name already exists
// Basic open network
await networkAPI.create_wlan('Public WiFi', '', 'default', 'default');
// Secure WPA2 network
await networkAPI.create_wlan(
'Corporate WiFi',
'strongpassword123',
'corporate_group',
'default',
true, // enabled
false, // visible SSID
false, // not guest
'wpapsk',
'wpa2',
'ccmp'
);
// Guest network with VLAN
await networkAPI.create_wlan(
'Guest Network',
'guestpass',
'guest_group',
'guest_wlan_group',
true, // enabled
false, // visible
true, // is guest
'wpapsk',
'wpa2',
'ccmp',
true, // VLAN enabled
'guest_vlan_id'
);
1.0.0
PHP: create_wlan($name, $x_passphrase, $usergroup_id, $wlangroup_id, $enabled = true, $hide_ssid = false, $is_guest = false, $security = 'open', $wpa_mode = 'wpa2', $wpa_enc = 'ccmp', $vlan_enabled = null, $vlan_id = null, $uapsd_enabled = false, $schedule_enabled = false, $schedule = [], $ap_group_ids = null, $payload = [])
List country codes
Retrieves a list of supported country codes for wireless regulatory compliance. Country codes determine allowed wireless channels and power levels.
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to an array of country code objects
When country code listing fails
// Get all supported country codes
const countryCodes = await networkAPI.list_country_codes();
console.log(`Supported countries: ${countryCodes.length}`);
// Find specific country
const usCode = countryCodes.find(country => country.code === 'US');
list_current_channels to see current channel usage
PHP: list_country_codes() -> return $this->fetch_results('/api/s/' . $this->site . '/stat/ccode');
List current channels
Retrieves information about currently used wireless channels across all Access Points. This helps with channel planning and interference analysis.
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to an array of current channel usage objects
When current channel listing fails
// Get current channel usage
const channels = await networkAPI.list_current_channels();
console.log(`Active channels: ${channels.length}`);
// Find 5GHz channels
const fiveGhzChannels = channels.filter(ch => ch.radio === 'na');
PHP: list_current_channels() -> return $this->fetch_results('/api/s/' . $this->site . '/stat/current-channel');
Spectrum scan
Initiates a spectrum scan on a specific Access Point to analyze wireless interference and channel utilization. This helps optimize wireless performance.
Required MAC address of the Access Point to perform spectrum scan
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if spectrum scan was initiated successfully
When MAC address is invalid
When spectrum scan initiation fails
// Start spectrum scan on specific AP
await networkAPI.spectrum_scan('aa:bb:cc:dd:ee:ff');
// Check scan results after completion
setTimeout(async () => {
const results = await networkAPI.spectrum_scan_state('aa:bb:cc:dd:ee:ff');
console.log('Scan results:', results);
}, 30000); // Wait 30 seconds for scan to complete
PHP: spectrum_scan($mac) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/cmd/devmgr', $payload);
Spectrum scan state
Retrieves the results of a spectrum scan performed on a specific Access Point. This provides detailed information about wireless interference and channel utilization.
Required MAC address of the Access Point to get spectrum scan results
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to spectrum scan results
When MAC address is invalid
When spectrum scan state retrieval fails
// Get spectrum scan results
const scanResults = await networkAPI.spectrum_scan_state('aa:bb:cc:dd:ee:ff');
// Analyze interference levels
if (scanResults.spectrum_table) {
const highInterference = scanResults.spectrum_table.filter(
entry => entry.utilization > 50
);
console.log(`High interference channels: ${highInterference.length}`);
}
PHP: spectrum_scan_state($mac) -> return $this->fetch_results('/api/s/' . $this->site . '/stat/spectrum-scan/' . strtolower(trim($mac)));
Create network
Creates a new network configuration in the UniFi Controller. Networks define IP subnets, VLAN settings, and routing policies.
Required Network configuration object
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to the created network configuration
When payload validation fails
When network creation fails
// Create a basic network
const network = await client.create_network({
name: 'Guest Network',
purpose: 'guest',
ip_subnet: '192.168.100.1/24',
networkgroup: 'LAN',
vlan_enabled: true,
vlan: 100
});
// Create VLAN network with DHCP
await client.create_network({
name: 'IoT Network',
purpose: 'vlan-only',
ip_subnet: '10.0.50.1/24',
vlan_enabled: true,
vlan: 50,
dhcpd_enabled: true,
dhcpd_start: '10.0.50.10',
dhcpd_stop: '10.0.50.200'
});
1.0.0
PHP: create_network($payload)
List network configurations
Retrieves network configurations from the UniFi Controller. Can optionally filter by specific network ID.
Optional network_id: stringOptional network configuration ID to filter by
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to network configuration(s)
When network retrieval fails
// Get all network configurations
const networks = await client.list_networkconf();
console.log(`Found ${networks.length} networks`);
// Get specific network by ID
const network = await client.list_networkconf('507f1f77bcf86cd799439011');
console.log(`Network: ${network.name} (${network.ip_subnet})`);
// Find networks by purpose
const allNetworks = await client.list_networkconf();
const guestNetworks = allNetworks.filter(net => net.purpose === 'guest');
const vlanNetworks = allNetworks.filter(net => net.vlan_enabled);
1.0.0
PHP: list_networkconf($network_id = '') -> return $this->fetch_results('/api/s/' . $this->site . '/rest/networkconf/' . trim($network_id));
Delete network
Deletes a network configuration from the UniFi Controller. This removes the network and all associated settings permanently.
Required Network configuration ID to delete
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if network deletion was successful
When network_id is invalid
When network deletion fails
// Delete a network by ID
await client.delete_network('507f1f77bcf86cd799439011');
// Find and delete a network by name
const networks = await client.list_networkconf();
const guestNetwork = networks.find(net => net.name === 'Guest Network');
if (guestNetwork) {
await client.delete_network(guestNetwork._id);
}
Deleting a network that is in use may cause connectivity issues
1.0.0
PHP: delete_network($network_id) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/networkconf/' . trim($network_id));
Update network settings, base
Updates network configuration settings for a specific network. This method allows modification of network parameters like DHCP settings, VLAN configuration, and other network properties.
Required Network configuration ID to update
Required Network configuration updates
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if network update was successful
When network_id is invalid or empty
When network update fails
// Update DHCP settings
await client.set_networksettings_base('507f1f77bcf86cd799439011', {
dhcpd_enabled: true,
dhcpd_start: '192.168.1.100',
dhcpd_stop: '192.168.1.200',
dhcpd_leasetime: 86400
});
// Enable VLAN on existing network
await client.set_networksettings_base('507f1f77bcf86cd799439011', {
vlan_enabled: true,
vlan: 50
});
// Update network name and purpose
await client.set_networksettings_base('507f1f77bcf86cd799439011', {
name: 'Updated Network Name',
purpose: 'corporate'
});
1.0.0
PHP: set_networksettings_base($network_id, $payload) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/networkconf/' . trim($network_id), $payload);
List routing rules
Retrieves routing rules configured in the UniFi Controller. Can optionally filter by specific route ID.
Optional route_id: stringOptional route ID to filter by
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to routing rule(s)
When routing rule retrieval fails
// Get all routing rules
const routes = await client.list_routing();
console.log(`Found ${routes.length} routing rules`);
// Get specific route by ID
const route = await client.list_routing('507f1f77bcf86cd799439011');
console.log(`Route: ${route.name} -> ${route.nexthop}`);
// Find routes by type
const allRoutes = await client.list_routing();
const staticRoutes = allRoutes.filter(route => route.type === 'static');
create_routing to create routing rules (if available)
1.0.0
PHP: list_routing($route_id = '') -> return $this->fetch_results('/api/s/' . $this->site . '/rest/routing/' . trim($route_id));
List port configurations
Retrieves port configuration profiles from the UniFi Controller. These profiles define VLAN assignments, PoE settings, and other port-specific configurations for switches.
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to port configuration profiles
When port configuration retrieval fails
// Get all port configurations
const portConfigs = await client.list_portconf();
console.log(`Found ${portConfigs.length} port configurations`);
// Find configurations by name
const voipConfig = portConfigs.find(config => config.name === 'VoIP');
if (voipConfig) {
console.log(`VoIP VLAN: ${voipConfig.native_networkconf_id}`);
}
create_portconf to create port configurations (if available)
1.0.0
PHP: list_portconf() -> return $this->fetch_results('/api/s/' . $this->site . '/list/portconf');
List port forwarding statistics
Retrieves statistics for port forwarding rules including traffic counters and connection information.
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to port forwarding statistics
When port forwarding statistics retrieval fails
// Get port forwarding statistics
const stats = await client.list_portforward_stats();
stats.forEach(stat => {
console.log(`Rule ${stat.name}: ${stat.tx_bytes} bytes transferred`);
});
list_portforwarding to get port forwarding rules
1.0.0
PHP: list_portforward_stats() -> return $this->fetch_results('/api/s/' . $this->site . '/stat/portforward_stats');
List port forwarding rules
Retrieves port forwarding rules configured in the UniFi Controller. These rules define how external traffic is forwarded to internal hosts.
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to port forwarding rules
When port forwarding rules retrieval fails
// Get all port forwarding rules
const rules = await client.list_portforwarding();
console.log(`Found ${rules.length} port forwarding rules`);
// Find rules by protocol
const httpRules = rules.filter(rule => rule.dst_port === '80');
const httpsRules = rules.filter(rule => rule.dst_port === '443');
create_portforwarding to create port forwarding rules (if available)
1.0.0
PHP: list_portforwarding() -> return $this->fetch_results('/api/s/' . $this->site . '/list/portforward');
Create DNS record
Creates a new DNS record in the UniFi Controller's DNS server. Supports various record types including A, AAAA, MX, TXT, SRV, and NS.
Required DNS record type
Required DNS record value
Required DNS record key/name
Optional ttl: numberOptional time-to-live in seconds
Optional whether the record is enabled (default: true)
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to the created DNS record
When record parameters are invalid
When DNS record creation fails
// Create A record
await client.create_dns_record('A', '192.168.1.100', 'server.local');
// Create CNAME record with TTL
await client.create_dns_record('CNAME', 'server.local', 'www.local', 3600);
// Create MX record
await client.create_dns_record('MX', '10 mail.local', 'local');
// Create disabled record
await client.create_dns_record('A', '192.168.1.200', 'test.local', 300, false);
1.0.0
PHP: create_dns_record($record_type, $value, $key, $ttl = null, $enabled = true)
List DNS records
Retrieves DNS records configured in the UniFi Controller's DNS server.
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to DNS records
When DNS records retrieval fails
// Get all DNS records
const records = await client.list_dns_records();
console.log(`Found ${records.length} DNS records`);
// Find records by type
const aRecords = records.filter(record => record.record_type === 'A');
const mxRecords = records.filter(record => record.record_type === 'MX');
1.0.0
PHP: list_dns_records() -> return $this->fetch_results('/api/s/' . $this->site . '/rest/dnsrecord');
Delete DNS record
Deletes a DNS record from the UniFi Controller's DNS server.
Required DNS record ID to delete
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if DNS record deletion was successful
When record_id is invalid
When DNS record deletion fails
// Delete a DNS record by ID
await client.delete_dns_record('507f1f77bcf86cd799439011');
// Find and delete a record by name
const records = await client.list_dns_records();
const testRecord = records.find(record => record.key === 'test.local');
if (testRecord) {
await client.delete_dns_record(testRecord._id);
}
1.0.0
PHP: delete_dns_record($record_id)
Create dynamic DNS configuration
Creates a new dynamic DNS configuration in the UniFi Controller. Dynamic DNS automatically updates DNS records when IP addresses change.
Required Dynamic DNS configuration object
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if dynamic DNS creation was successful
When payload validation fails
When dynamic DNS creation fails
// Create dynamic DNS configuration
await client.create_dynamicdns({
service: 'dyndns',
host_name: 'myhost.dyndns.org',
username: 'myusername',
password: 'mypassword',
enabled: true
});
1.0.0
PHP: create_dynamicdns($payload) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/dynamicdns', $payload);
List dynamic DNS configurations
Retrieves dynamic DNS configurations from the UniFi Controller.
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to dynamic DNS configurations
When dynamic DNS retrieval fails
// Get all dynamic DNS configurations
const configs = await client.list_dynamicdns();
console.log(`Found ${configs.length} dynamic DNS configurations`);
// Find enabled configurations
const enabledConfigs = configs.filter(config => config.enabled);
1.0.0
PHP: list_dynamicdns() -> return $this->fetch_results('/api/s/' . $this->site . '/rest/dynamicdns');
Update dynamic DNS configuration
Updates an existing dynamic DNS configuration in the UniFi Controller.
Required Dynamic DNS configuration ID to update
Required Dynamic DNS configuration updates
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if dynamic DNS update was successful
When dynamicdns_id is invalid or empty
When dynamic DNS update fails
// Update dynamic DNS configuration
await client.set_dynamicdns('507f1f77bcf86cd799439011', {
enabled: false,
host_name: 'newhost.dyndns.org'
});
// Change credentials
await client.set_dynamicdns('507f1f77bcf86cd799439011', {
username: 'newusername',
password: 'newpassword'
});
1.0.0
PHP: set_dynamicdns($dynamicdns_id, $payload) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/dynamicdns/' . trim($dynamicdns_id), $payload);
Delete WLAN
Permanently deletes a WLAN configuration from the UniFi Controller. This removes the wireless network and all associated settings.
Required WLAN configuration ID to delete
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if WLAN deletion was successful
When wlan_id is invalid
When WLAN deletion fails
// Delete a WLAN by ID
await networkAPI.delete_wlan('507f1f77bcf86cd799439011');
// Find and delete WLAN by name
const wlans = await networkAPI.list_wlanconf();
const guestWlan = wlans.find(wlan => wlan.name === 'Guest Network');
if (guestWlan) {
await networkAPI.delete_wlan(guestWlan._id);
}
Deleting a WLAN will disconnect all clients using that network
PHP: delete_wlan($wlan_id) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/wlanconf/' . trim($wlan_id));
Disable WLAN
Temporarily disables or enables a WLAN without deleting the configuration. This allows you to quickly turn wireless networks on/off as needed.
Required WLAN configuration ID to disable/enable
Required Whether to disable (true) or enable (false) the WLAN
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if WLAN disable/enable was successful
When wlan_id is invalid
When WLAN disable/enable fails
// Disable a WLAN
await networkAPI.disable_wlan('507f1f77bcf86cd799439011', true);
// Enable a WLAN
await networkAPI.disable_wlan('507f1f77bcf86cd799439011', false);
// Find and disable guest network during maintenance
const wlans = await networkAPI.list_wlanconf();
const guestWlan = wlans.find(wlan => wlan.name === 'Guest Network');
if (guestWlan) {
await networkAPI.disable_wlan(guestWlan._id, true);
}
PHP: disable_wlan($wlan_id, $disable) -> return $this->set_wlansettings_base($wlan_id, $payload);
List WLAN groups
Retrieves a list of WLAN groups configured in the UniFi Controller. WLAN groups allow you to organize and manage wireless networks across different Access Points.
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to an array of WLAN group objects
When WLAN group listing fails
// Get all WLAN groups
const wlanGroups = await networkAPI.list_wlan_groups();
console.log(`Found ${wlanGroups.length} WLAN groups`);
// Find a specific WLAN group
const defaultGroup = wlanGroups.find(group => group.name === 'Default');
PHP: list_wlan_groups() -> return $this->fetch_results('/api/s/' . $this->site . '/list/wlangroup');
List WLAN configuration
Retrieves a list of all WLAN (wireless network) configurations from the UniFi Controller. This includes SSIDs, security settings, user groups, and other wireless network parameters.
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to an array of WLAN configuration objects
When WLAN configuration listing fails
// Get all WLAN configurations
const wlans = await networkAPI.list_wlanconf();
console.log(`Found ${wlans.length} wireless networks`);
// Filter enabled WLANs only
const enabledWlans = wlans.filter(wlan => wlan.enabled);
// Find guest networks
const guestWlans = wlans.filter(wlan => wlan.is_guest);
PHP: list_wlanconf() -> return $this->fetch_results('/api/s/' . $this->site . '/list/wlanconf');
Set WLAN settings
Updates WLAN configuration settings with the provided payload. This is a high-level method that delegates to set_wlansettings_base.
Required WLAN configuration ID to update
Required Configuration settings to update
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if WLAN settings update was successful
When wlan_id or payload is invalid
When WLAN settings update fails
// Update WLAN security settings
await networkAPI.set_wlansettings('507f1f77bcf86cd799439011', {
security: 'wpapsk',
wpa_mode: 'wpa2',
x_passphrase: 'newpassword123'
});
// Enable/disable WLAN
await networkAPI.set_wlansettings('507f1f77bcf86cd799439011', {
enabled: false
});
PHP: set_wlansettings($wlan_id, $payload) -> return $this->set_wlansettings_base($wlan_id, $payload);
Set WLAN settings base
Low-level method to update WLAN configuration settings directly. This method provides direct access to the UniFi Controller's WLAN configuration API.
Required WLAN configuration ID to update
Required Configuration settings to update
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if WLAN settings update was successful
When wlan_id or payload is invalid
When WLAN settings update fails
// Update multiple WLAN settings
await networkAPI.set_wlansettings_base('507f1f77bcf86cd799439011', {
name: 'Updated Network Name',
enabled: true,
hide_ssid: false,
security: 'wpapsk',
wpa_mode: 'wpa2',
wpa_enc: 'ccmp',
x_passphrase: 'newsecurepassword'
});
PHP: set_wlansettings_base($wlan_id, $payload) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/wlanconf/' . trim($wlan_id), $payload);
Move device
Moves a UniFi device from the current site to another site. This is useful for reorganizing devices across different site configurations.