Site identifier (defaults to 'default')
Required MAC address of the client device to block
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if blocking was successful
When MAC address validation fails
When client blocking fails
// Block a client device
await clientAPI.block_sta('default', 'aa:bb:cc:dd:ee:ff');
// Block with cancellation support
const controller = new AbortController();
await clientAPI.block_sta('default', 'aa:bb:cc:dd:ee:ff', { signal: controller.signal });
PHP: block_sta($mac) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/cmd/stamgr', $payload);
Create hotspot operator
Creates a new hotspot operator account for managing guest access. Hotspot operators can create and manage vouchers for guest network access.
Required Username for the hotspot operator
Required Password for the hotspot operator
Optional note/description for the operator (default: '')
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if hotspot operator creation was successful
When name or password is invalid
When hotspot operator creation fails
// Create basic hotspot operator
await clientAPI.create_hotspotop('reception', 'securepassword123');
// Create hotspot operator with note
await clientAPI.create_hotspotop(
'conference_desk',
'conf2024!',
'Conference registration desk operator'
);
PHP: create_hotspotop($name, $x_password, $note = '')
List hotspot operators
Retrieves a list of all hotspot operators configured in the UniFi Controller. Hotspot operators can manage guest access and create vouchers.
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to an array of hotspot operator objects
When hotspot operator listing fails
// Get all hotspot operators
const operators = await clientAPI.list_hotspotop();
console.log(`Found ${operators.length} hotspot operators`);
// Find specific operator
const receptionOp = operators.find(op => op.name === 'reception');
if (receptionOp) {
console.log(`Reception operator note: ${receptionOp.note}`);
}
create_hotspotop to create new operators
PHP: list_hotspotop() -> return $this->fetch_results('/api/s/' . $this->site . '/list/hotspotop');
List all client devices (users/stations) connected to the UniFi network
Site identifier (defaults to 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal for request cancellation
Promise resolving to an array of UniFi client objects
Retrieves a list of all client devices that have connected to the UniFi network. This includes both currently connected and previously connected devices.
// Get all clients
const clients = await clientAPI.list_users();
console.log(`Found ${clients.length} clients`);
// With request cancellation
const controller = new AbortController();
const clients = await clientAPI.list_users('default', { signal: controller.signal });
1.0.0
PHP: list_users() -> return $this->fetch_results('/api/s/' . $this->site . '/list/user');
Authorize a guest client device for network access
Site identifier (defaults to 'default')
Required MAC address of the guest device to authorize
Required Duration in minutes for which the guest access is valid
Optional up: numberOptional upload bandwidth limit in Kbps (e.g., 5000 = 5 Mbps)
Optional down: numberOptional download bandwidth limit in Kbps (e.g., 10000 = 10 Mbps)
Optional megabytes: numberOptional data usage limit in megabytes
Optional ap_mac: stringOptional MAC address of specific Access Point to restrict access to
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal for request cancellation
Promise resolving to true if authorization was successful
Grants network access to a guest device for a specified duration with optional bandwidth and data limits. The device will be automatically unauthorized after the time expires.
When MAC address format is invalid
When device is already authorized or authorization fails
// Basic guest authorization for 60 minutes
await clientAPI.authorize_guest('default', 'aa:bb:cc:dd:ee:ff', 60);
// With bandwidth limits (5 Mbps up, 10 Mbps down)
await clientAPI.authorize_guest('default', 'aa:bb:cc:dd:ee:ff', 120, 5000, 10000);
// With data limit (1 GB)
await clientAPI.authorize_guest('default', 'aa:bb:cc:dd:ee:ff', 180, undefined, undefined, 1024);
// Restrict to specific Access Point
await clientAPI.authorize_guest(
'default',
'aa:bb:cc:dd:ee:ff',
240,
2000,
5000,
512,
'11:22:33:44:55:66'
);
1.0.0
PHP: authorize_guest($mac, $minutes, $up = null, $down = null, $megabytes = null, $ap_mac = null)
Protected substituteProtected makeList active client devices PHP: list_active_clients($include_traffic_usage = true, $include_unifi_devices = true)
Optional options: { Optional signal?: AbortSignalList client devices PHP: list_clients($mac = '') -> return $this->fetch_results('/api/s/' . $this->site . '/stat/sta', $payload);
Optional mac: stringOptional options: { Optional signal?: AbortSignalList client history PHP: list_clients_history($historyhours = 8760, $start = null, $end = null, $mac = null) -> return $this->fetch_results('/api/s/' . $this->site . '/stat/sta', $payload);
Optional start: numberOptional end: numberOptional mac: stringOptional options: { Optional signal?: AbortSignalFetch details for a single client device PHP: stat_client($mac) -> return $this->fetch_results('/api/s/' . $this->site . '/stat/user/' . strtolower(trim($mac)));
Optional options: { Optional signal?: AbortSignalUnblock a station PHP: unblock_sta($mac) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/cmd/stamgr', $payload);
Optional options: { Optional signal?: AbortSignalReconnect client device (kick and reconnect) PHP: reconnect_sta($mac) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/cmd/stamgr', $payload);
Optional options: { Optional signal?: AbortSignalForget client device PHP: forget_sta($mac) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/cmd/stamgr', $payload);
Optional options: { Optional signal?: AbortSignalEdit client fixed IP PHP: edit_client_fixedip($client_id, $use_fixedip, $network_id = null, $fixed_ip = null)
Optional network_id: stringOptional fixed_ip: stringOptional options: { Optional signal?: AbortSignalSet client device name PHP: set_sta_name($user_id, $name = '') -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/upd/user/' . trim($user_id), $payload);
Optional options: { Optional signal?: AbortSignalSet client device note PHP: set_sta_note($user_id, $note = '') -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/upd/user/' . trim($user_id), $payload);
Optional options: { Optional signal?: AbortSignalUnauthorize a guest PHP: unauthorize_guest($mac) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/cmd/stamgr', $payload);
Optional options: { Optional signal?: AbortSignalExtend guest validity PHP: extend_guest_validity($guest_id) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/cmd/hotspot', $payload);
Optional options: { Optional signal?: AbortSignalList guest devices PHP: list_guests($within = 8760) -> return $this->fetch_results('/api/s/' . $this->site . '/stat/guest', $payload);
Optional options: { Optional signal?: AbortSignalFetch sessions PHP: stat_sessions($start = null, $end = null, $mac = null, $type = 'all') -> return $this->fetch_results('/api/s/' . $this->site . '/stat/session', $payload);
Optional start: numberOptional end: numberOptional mac: stringOptional options: { Optional signal?: AbortSignalFetch latest sessions for a station PHP: stat_sta_sessions_latest($mac, $limit = null) -> return $this->fetch_results('/api/s/' . $this->site . '/stat/session', $payload);
Optional limit: numberOptional options: { Optional signal?: AbortSignalCreate tag
Creates a new tag for organizing and managing client devices. Tags can be used to group devices for easier management and policy application.
Required Name for the new tag
Optional macs: string[]Optional array of MAC addresses to initially assign to this tag
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if tag creation was successful
When name is invalid
When tag creation fails
// Create empty tag
await clientAPI.create_tag('VIP Devices');
// Create tag with initial devices
await clientAPI.create_tag('Conference Room', [
'aa:bb:cc:dd:ee:ff',
'ff:ee:dd:cc:bb:aa'
]);
PHP: create_tag($name, $macs = null)
Delete tag
Permanently deletes a tag from the UniFi Controller. This removes the tag and all device associations.
Required Tag 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 tag deletion was successful
When tag_id is invalid
When tag deletion fails
// Delete tag by ID
await clientAPI.delete_tag('507f1f77bcf86cd799439011');
// Find and delete tag by name
const tags = await clientAPI.list_tags();
const oldTag = tags.find(tag => tag.name === 'Old Devices');
if (oldTag) {
await clientAPI.delete_tag(oldTag._id);
}
This operation removes all device associations with the tag
PHP: delete_tag($tag_id) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/tag/' . $tag_id);
Get tag
Retrieves detailed information about a specific tag including its member devices.
Required Tag ID to retrieve
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to tag information object
When tag_id is invalid
When tag retrieval fails
// Get specific tag details
const tag = await clientAPI.get_tag('507f1f77bcf86cd799439011');
console.log(`Tag "${tag.name}" has ${tag.member_table?.length || 0} devices`);
// Check if device is in tag
const deviceMac = 'aa:bb:cc:dd:ee:ff';
const isTagged = tag.member_table?.includes(deviceMac.toLowerCase());
PHP: get_tag($tag_id) -> return $this->fetch_results('/api/s/' . $this->site . '/rest/tag/' . $tag_id);
List tags
Retrieves a list of all tags configured in the UniFi Controller. Tags are used for organizing and managing client devices.
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to an array of tag objects
When tag listing fails
// Get all tags
const tags = await clientAPI.list_tags();
console.log(`Found ${tags.length} tags`);
// Find tags with devices
const activeTags = tags.filter(tag =>
tag.member_table && tag.member_table.length > 0
);
// Get tag names
const tagNames = tags.map(tag => tag.name);
PHP: list_tags() -> return $this->fetch_results('/api/s/' . $this->site . '/list/tag');
Set tagged devices
Updates the list of devices associated with a specific tag. This replaces the current device list with the provided MAC addresses.
Required Tag ID to update
Required Array of MAC addresses to assign to this tag
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if tag device assignment was successful
When tag_id or device_macs is invalid
When tag device assignment fails
// Assign devices to tag
await clientAPI.set_tagged_devices('507f1f77bcf86cd799439011', [
'aa:bb:cc:dd:ee:ff',
'ff:ee:dd:cc:bb:aa',
'11:22:33:44:55:66'
]);
// Clear all devices from tag
await clientAPI.set_tagged_devices('507f1f77bcf86cd799439011', []);
// Add single device to tag (replacing all others)
await clientAPI.set_tagged_devices('507f1f77bcf86cd799439011', [
'aa:bb:cc:dd:ee:ff'
]);
This replaces the entire device list - existing devices not in the array will be removed
PHP: set_tagged_devices($tag_id, $device_macs) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/tag/' . $tag_id, $payload);
Create voucher
Creates guest access vouchers with specified duration, bandwidth limits, and usage quotas. Vouchers provide temporary network access without requiring device registration.
Required Voucher validity duration in minutes
Number of vouchers to create (default: 1)
Usage quota per voucher (0 = unlimited) (default: 0)
Optional note/description for the vouchers (default: '')
Optional up: numberOptional upload bandwidth limit in Kbps
Optional down: numberOptional download bandwidth limit in Kbps
Optional megabytes: numberOptional data usage limit in megabytes
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to voucher creation result
When parameters are invalid
When voucher creation fails
// Create single voucher for 60 minutes
const voucher = await clientAPI.create_voucher(60);
// Create 10 vouchers with bandwidth limits (5 Mbps down, 2 Mbps up)
await clientAPI.create_voucher(
120, // 2 hours
10, // 10 vouchers
0, // unlimited usage
'Conference guests',
2000, // 2 Mbps up
5000 // 5 Mbps down
);
// Create voucher with data limit (500 MB)
await clientAPI.create_voucher(
180, // 3 hours
1, // 1 voucher
0, // unlimited usage
'Limited data access',
undefined, // no upload limit
undefined, // no download limit
500 // 500 MB data limit
);
PHP: create_voucher($minutes, $count = 1, $quota = 0, $note = '', $up = null, $down = null, $megabytes = null)
Revoke voucher
Revokes (deletes) a specific voucher, making it invalid for future use. This does not affect currently active sessions using the voucher.
Required Voucher ID to revoke
Site identifier (default: 'default')
Optional options: { Optional request configuration
Optional signal?: AbortSignalOptional AbortSignal to cancel the request
Promise resolving to true if voucher revocation was successful
When voucher_id is invalid
When voucher revocation fails
// Revoke specific voucher
await clientAPI.revoke_voucher('507f1f77bcf86cd799439011');
// Find and revoke vouchers by note
const vouchers = await clientAPI.stat_voucher();
const conferenceVouchers = vouchers.filter(v =>
v.note && v.note.includes('Conference')
);
for (const voucher of conferenceVouchers) {
await clientAPI.revoke_voucher(voucher._id);
}
This permanently deletes the voucher - it cannot be recovered
PHP: revoke_voucher($voucher_id) -> return $this->fetch_results_boolean('/api/s/' . $this->site . '/cmd/hotspot', $payload);
Block a client device
Blocks network access for a specific client device by MAC address. The device will be unable to connect to the network until unblocked.