| Both sides previous revision Previous revision Next revision | Previous revision |
| products:software:unifi-controller:api [2021/09/18 00:53] – Added example for rest/setting PUT template khalilio | products:software:unifi-controller:api [2025/05/12 13:37] (current) – external edit 127.0.0.1 |
|---|
| </code> | </code> |
| |
| ==== UDM Pro API ==== | ==== UDM Pro and UCG Max API ==== |
| |
| **NOTE:** There are two critical differences between Unifi controllers and the UDM Pro's API: | **NOTE:** There are two critical differences between Unifi controllers and the API of the UDM Pro and UCG Max: |
| |
| * The login endpoint is **''/api/auth/login''** | * The login endpoint is **''/api/auth/login''** |
| <panel title="curl"> | <panel title="curl"> |
| <code> | <code> |
| curl -k -X POST --data '{"username": "usr", "password": "$pw"}' -b cookie.txt https://udmp:443/proxy/network/api/auth/login | # authenticate and save the cookie contents in local file cookie.txt with switch '-c' |
| # responds with 'Not Found' | curl -k -X POST --data '{"username": "usr", "password": "$pw"}' --header 'Content-Type: application/json' -c cookie.txt https://udmp:443/api/auth/login |
| | # responds with json data |
| | |
| | # pass the local file cookie.txt with switch '-b' |
| curl -k -X GET -b cookie.txt https://udmp/proxy/network/api/s/default/self | curl -k -X GET -b cookie.txt https://udmp/proxy/network/api/s/default/self |
| # responds with proper json | # responds with proper json |
| | status | GET | Returns some very basic server information - This appears to be the only endpoint that can be reached without an authentication | | | status | GET | Returns some very basic server information - This appears to be the only endpoint that can be reached without an authentication | |
| | <code> { "data" : [ ] , "meta" : { "rc" : "ok" , "server_version" : "5.7.23" , "up" : true , "uuid" : "0e727580-ffff-ffff-ffff-403dcd5a7bd4"}} </code> ||| | | <code> { "data" : [ ] , "meta" : { "rc" : "ok" , "server_version" : "5.7.23" , "up" : true , "uuid" : "0e727580-ffff-ffff-ffff-403dcd5a7bd4"}} </code> ||| |
| | api/login | POST | requires dict of username, password, and optionally remember=true for long-running sessions. Returns 200 for success and a cooke that is your session. **NOTE:** On UDM Pros this is api/auth/login. | | | api/login | POST | requires dict of username, password, and optionally remember=true for long-running sessions. Returns 200 for success and a cookie that is your session. **NOTE:** On UDM Pros this is api/auth/login. | |
| | api/logout | POST | destroys the sever side session id which will make future attempts with that cookie fail | | | api/logout | POST | destroys the sever side session id which will make future attempts with that cookie fail | |
| | api/self | GET | Logged in user **NOTE:** On UDM Pros this is api/users/self. | | | api/self | GET | Logged in user **NOTE:** On UDM Pros this is api/users/self. | |
| | stat/sysinfo | GET | Some high-level information about the controller | | | stat/sysinfo | GET | Some high-level information about the controller | |
| | stat/event | GET | List site events by most recent first, 3000 result limit | | | stat/event | GET | List site events by most recent first, 3000 result limit | |
| | rest/event | GET | List site events by oldest, no limit? | | | rest/event | GET | List site events by oldest, no limit? (api.err.NotFound per controller version 7.1.66) | |
| | stat/alarm | GET | List alarms by most recent, 3000 result limit? | | | stat/alarm | GET | List alarms by most recent, 3000 result limit? | |
| | rest/alarm | GET | List alarms by oldest, no limit? | | | rest/alarm | GET | List alarms by oldest, no limit? (api.err.NotFound per controller version 7.1.66) | |
| | stat/sta | GET | List of all _active_ clients on the site | | | stat/sta | GET | List of all _active_ clients on the site | |
| | rest/user | GET/POST/PUT | List of all configured/known clients on the site | | | rest/user | GET/POST/PUT | List of all configured/known clients on the site | |
| | stat/device-basic | GET | List of site devices with only 'adopted', 'disabled', 'mac', 'state', 'type' keys, useful for filtering on type | | | stat/device-basic | GET | List of site devices with only 'adopted', 'disabled', 'mac', 'state', 'type' keys, useful for filtering on type | |
| | stat/device | GET/POST | Detailed list of all devices on site. Can be filtered by posting ''%%{"macs": ["mac1", ... ]}%%'' | | | stat/device | GET/POST | Detailed list of all devices on site. (**Controller only**) Can be filtered by POSTing ''%%{"macs": ["mac1", ... ]}%%'' | |
| | | stat/device/{mac} | GET | (**UDM only**) Detailed list of device filtered by mac address | |
| | rest/device/{_id} | PUT | Updates to devices get PUT here, why? | | | rest/device/{_id} | PUT | Updates to devices get PUT here, why? | |
| | rest/setting | GET/PUT | Detailed site settings, updating requires adding key and _id to path for PUT ../setting/{key}/{_id} | | | rest/setting | GET/PUT | Detailed site settings, updating requires adding key and _id to path for PUT ../setting/{key}/{_id} | |
| | stat/routing | GET | All active routes on the device | | | stat/routing | GET | All active routes on the device | |
| | rest/routing | GET/PUT | User defined routes | | | rest/routing | GET/PUT | User defined routes (HTTP response 500 per controller version 7.1.66) | |
| | rest/firewallrule | GET/PUT | User defined firewall rules. This does not show auto-generated rules | | | rest/firewallrule | GET/PUT | User defined firewall rules. This does not show auto-generated rules | |
| | rest/firewallgroup | GET/PUT | User defined firewall groups. | | | rest/firewallgroup | GET/PUT | User defined firewall groups. | |
| | rest/wlanconf | GET/PUT | List WLANs, edit current WLANs and create new WLANs | | | rest/wlanconf | GET/PUT | List WLANs, edit current WLANs and create new WLANs | |
| | rest/wlanconf/{_id} | PUT | Update configuration of current WLAN designated by '_id' | | | rest/wlanconf/{_id} | GET | Get details of WLAN designated by '_id' | |
| | rest/tag | GET/PUT? | Tagged macs | | | rest/wlanconf/{_id} | PUT | Update configuration of current WLAN designated by '_id' | |
| | | rest/tag | GET/PUT? | Tagged macs (api.err.Invalid per controller version 7.1.66) | |
| | stat/rogueap | GET/POST | Neighboring APs optional json post 'within' = seen in the last x hours | | | stat/rogueap | GET/POST | Neighboring APs optional json post 'within' = seen in the last x hours | |
| | stat/sitedpi | GET/POST | DPI stats requires type="by_app" or "by_cat" | | | stat/sitedpi | GET/POST | DPI stats requires type="by_app" or "by_cat" | |
| | rest/portforward | GET | List all port forwards configured on the site | | | rest/portforward | GET | List all port forwards configured on the site | |
| | stat/report/{interval}.{type} | POST | Intervals are '5minutes', 'hourly', and 'daily'. Report types are 'site', 'user', and 'ap'. Must specify attributes to be returned 'bytes', 'wan-tx_bytes', 'wan-rx_bytes', 'wlan_bytes', 'num_sta', 'lan-num_sta', 'wlan-num_sta', 'time', 'rx_bytes', 'tx_bytes'. Can be filtered with 'macs': [...] | | | stat/report/{interval}.{type} | POST | Intervals are '5minutes', 'hourly', and 'daily'. Report types are 'site', 'user', and 'ap'. Must specify attributes to be returned 'bytes', 'wan-tx_bytes', 'wan-rx_bytes', 'wlan_bytes', 'num_sta', 'lan-num_sta', 'wlan-num_sta', 'time', 'rx_bytes', 'tx_bytes'. Can be filtered with 'macs': [...] | |
| | | stat/authorization | POST | JSON as "%%{"start": "START TIMESTAMP", "end": "END TIMESTAMP"}%%" and you will get the code that have been used between the Timestams NOTE: X-CSRF-Token header required (from e.g. the login response) for UDM | |
| | | stat/sdn | GET | Return values as if the site is connected with the Unifi Cloud or the SSO | |
| |
| === Callable commands === | === Callable commands === |
| This data was extracted from the javascript of the site. | This data was extracted from the javascript of the site. |
| |
| ^ Device Code ^ Device Type ^ Device Name ^ | ^ Model ^ Type ^ SKU | Name | |
| | BZ2 | uap | UniFi AP | | | BZ2 | uap | UAP | Access Point | |
| | BZ2LR | uap | UniFi AP-LR | | | BZ2LR | uap | UAP-LR | Access Point Long-Range | |
| | U2HSR | uap | UniFi AP-Outdoor+ | | | S216150 | usw | US-16-150W | Switch 16 PoE (150 W) | |
| | U2IW | uap | UniFi AP-In Wall | | | S224250 | usw | US-24-250W | Switch 24 PoE (250 W) | |
| | U2L48 | uap | UniFi AP-LR | | | S224500 | usw | US-24-500W | Switch 24 PoE (500 W) | |
| | U2Lv2 | uap | UniFi AP-LR v2 | | | S248500 | usw | US-48-500W | Switch 48 PoE (500 W) | |
| | U2M | uap | UniFi AP-Mini | | | S248750 | usw | US-48-750W | Switch 48 PoE (750 W) | |
| | U2O | uap | UniFi AP-Outdoor | | | S28150 | usw | US-8-150W | Switch 8 PoE (150 W) | |
| | U2S48 | uap | UniFi AP | | | U2HSR | uap | UAP-Outdoor+ | Access Point Outdoor+ | |
| | U2Sv2 | uap | UniFi AP v2 | | | U2IW | uap | UAP-IW | Access Point In-Wall | |
| | U5O | uap | UniFi AP-Outdoor 5G | | | U2L48 | uap | UAP-LR | Access Point Long-Range | |
| | U7E | uap | UniFi AP-AC | | | U2Lv2 | uap | UAP-LRv2 | Access Point Long-Range | |
| | U7EDU | uap | UniFi AP-AC-EDU | | | U2M | uap | UAP-Mini | Access Point Mini | |
| | U7Ev2 | uap | UniFi AP-AC v2 | | | U2O | uap | UAP-Outdoor | Access Point Outdoor | |
| | U7HD | uap | UniFi AP-HD | | | U2S48 | uap | UAP | Access Point | |
| | U7SHD | uap | UniFi AP-SHD | | | U2Sv2 | uap | UAPv2 | Access Point | |
| | U7NHD | uap | UniFi AP-nanoHD | | | U5O | uap | UAP-Outdoor5 | Access Point Outdoor 5 | |
| | UFLHD | uap | UniFi AP-Flex-HD | | | U6ENT | uap | U6-Enterprise | Access Point WiFi 6 Enterprise | |
| | UHDIW | uap | UniFi AP-HD-In Wall | | | U6EXT | uap | U6-Extender | Access Point WiFi 6 Extender | |
| | UCXG | uap | UniFi AP-XG | | | U6IW | uap | U6-IW | Access Point WiFi 6 In-Wall | |
| | UXSDM | uap | UniFi AP-BaseStationXG | | | U6M | uap | U6-Mesh | Access Point WiFi 6 Mesh | |
| | UCMSH | uap | UniFi AP-MeshXG | | | U7E | uap | UAP-AC | Access Point AC | |
| | U7IW | uap | UniFi AP-AC-In Wall | | | U7EDU | uap | UAP-AC-EDU | Access Point AC EDU | |
| | U7IWP | uap | UniFi AP-AC-In Wall Pro | | | U7Ev2 | uap | UAP-AC | Access Point AC | |
| | U7MP | uap | UniFi AP-AC-Mesh-Pro | | | U7HD | uap | UAP-AC-HD | Access Point AC HD | |
| | U7LR | uap | UniFi AP-AC-LR | | | U7IW | uap | UAP-AC-IW | Access Point AC In-Wall | |
| | U7LT | uap | UniFi AP-AC-Lite | | | U7IWP | uap | UAP-AC-IW-Pro | Access Point AC In-Wall Pro | |
| | U7O | uap | UniFi AP-AC Outdoor | | | U7LR | uap | UAP-AC-LR | Access Point AC Long-Range | |
| | U7P | uap | UniFi AP-Pro | | | U7LT | uap | UAP-AC-Lite | Access Point AC Lite | |
| | U7MSH | uap | UniFi AP-AC-Mesh | | | U7MP | uap | UAP-AC-M-Pro | Access Point AC Mesh Pro | |
| | U7PG2 | uap | UniFi AP-AC-Pro | | | U7MSH | uap | UAP-AC-M | Access Point AC Mesh | |
| | p2N | uap | PicoStation M2 | | | U7NHD | uap | UAP-nanoHD | Access Point nanoHD | |
| | US48PRO | usw | UniFi Switch Pro 48 | | | U7O | uap | UAP-AC-Outdoor | Access Point AC Outdoor | |
| | US8 | usw | UniFi Switch 8 | | | U7P | uap | UAP-AC-Pro | Access Point AC Pro | |
| | US8P60 | usw | UniFi Switch 8 POE-60W | | | U7PG2 | uap | UAP-AC-Pro | Access Point AC Pro | |
| | US8P150 | usw | UniFi Switch 8 POE-150W | | | U7SHD | uap | UAP-AC-SHD | Access Point AC SHD | |
| | S28150 | usw | UniFi Switch 8 AT-150W | | | UAE6 | uap | U6-Extender-EA | Access Point WiFi 6 Extender | |
| | USC8 | usw | UniFi Switch 8 | | | UAIW6 | uap | U6-IW-EA | Access Point WiFi 6 In-Wall | |
| | US16P150 | usw | UniFi Switch 16 POE-150W | | | UAL6 | uap | U6-Lite | Access Point WiFi 6 Lite | |
| | S216150 | usw | UniFi Switch 16 AT-150W | | | UALR6 | uap | U6-LR-EA | Access Point WiFi 6 Long-Range | |
| | US24 | usw | UniFi Switch 24 | | | UALR6v2 | uap | U6-LR | Access Point WiFi 6 Long-Range | |
| | US24P250 | usw | UniFi Switch 24 POE-250W | | | UALR6v3 | uap | U6-LR | Access Point WiFi 6 Long-Range | |
| | US24PL2 | usw | UniFi Switch 24 L2 POE | | | UAM6 | uap | U6-Mesh-EA | Access Point WiFi 6 Mesh | |
| | US24P500 | usw | UniFi Switch 24 POE-500W | | | UAP6 | uap | U6-LR | Access Point WiFi 6 Long-Range | |
| | S224250 | usw | UniFi Switch 24 AT-250W | | | UAP6MP | uap | U6-Pro | Access Point WiFi 6 Pro | |
| | S224500 | usw | UniFi Switch 24 AT-500W | | | UASXG | uas | UAS-XG | Application Server XG | |
| | US48 | usw | UniFi Switch 48 | | | UBB | ubb | UBB | Building-to-Building Bridge | |
| | US48P500 | usw | UniFi Switch 48 POE-500W | | | UBBXG | ubb | UBB-XG | Building-to-Building Bridge XG | |
| | US48PL2 | usw | UniFi Switch 48 L2 POE | | | UCGMAX | ucg | UCG-MAX | Cloud Gateway Max | |
| | US48P750 | usw | UniFi Switch 48 POE-750W | | | UCK | uck | UCK | Cloud Key | |
| | S248500 | usw | UniFi Switch 48 AT-500W | | | UCK-v2 | uck | UCK | Cloud Key | |
| | S248750 | usw | UniFi Switch 48 AT-750W | | | UCK-v3 | uck | UCK | Cloud Key | |
| | US6XG150 | usw | UniFi Switch 6XG POE-150W | | | UCKG2 | uck | UCK-G2 | Cloud Key Gen2 | |
| | USXG | usw | UniFi Switch 16XG | | | UCKP | uck | UCK-G2-Plus | Cloud Key Gen2 Plus | |
| | UGW3 | ugw | UniFi Security Gateway 3P | | | UCMSH | uap | UAP-XG-Mesh | Access Point Mesh XG | |
| | UGW4 | ugw | UniFi Security Gateway 4P | | | UCXG | uap | UAP-XG | Access Point XG | |
| | UGWHD4 | ugw | UniFi Security Gateway HD | | | UDC48X6 | usw | USW-Leaf | Switch Leaf | |
| | UGWXG | ugw | UniFi Security Gateway XG-8 | | | UDM | udm | UDM | Dream Machine | |
| | UP4 | uph | UniFi Phone-X | | | UDMB | uap | UAP-BeaconHD | Access Point BeaconHD | |
| | UP5 | uph | UniFi Phone | | | UDMPRO | udm | UDM-Pro | Dream Machine Pro | |
| | UP5t | uph | UniFi Phone-Pro | | | UDMPROSE | udm | UDM-SE | Dream Machine Special Edition | |
| | UP7 | uph | UniFi Phone-Executive | | | UDR | udm | UDR | Dream Router | |
| | UP5c | uph | UniFi Phone | | | UDW | udm | UDW | Dream Wall | |
| | UP5tc | uph | UniFi Phone-Pro | | | UDWPRO | udm | UDWPRO | Dream Wall Pro | |
| | UP7c | uph | UniFi Phone-Executive | | | UFLHD | uap | UAP-FlexHD | Access Point FlexHD | |
| | | UGW3 | ugw | USG-3P | Security Gateway | |
| | | UGW4 | ugw | USG-Pro-4 | Security Gateway Pro | |
| | | UGWHD4 | ugw | USG | Security Gateway | |
| | | UGWXG | ugw | USG-XG-8 | Security Gateway XG | |
| | | UHDIW | uap | UAP-IW-HD | Access Point In-Wall HD | |
| | | ULTE | uap | U-LTE | UniFi LTE | |
| | | ULTEPEU | uap | U-LTE-Pro | UniFi LTE Pro | |
| | | ULTEPUS | uap | U-LTE-Pro | UniFi LTE Pro | |
| | | UP1 | uap | USP-Plug | SmartPower Plug | |
| | | UP4 | uph | UVP-X | Phone | |
| | | UP5 | uph | UVP | Phone | |
| | | UP5c | uph | UVP | Phone | |
| | | UP5t | uph | UVP-Pro | Phone Professional | |
| | | UP5tc | uph | UVP-Pro | Phone Professional | |
| | | UP6 | uap | USP-Strip | SmartPower Strip (6 ports) | |
| | | UP7 | uph | UVP-Executive | Phone Executive | |
| | | UP7c | uph | UVP-Executive | Phone Executive | |
| | | US16P150 | usw | US-16-150W | Switch 16 PoE (150 W) | |
| | | US24 | usw | USW-24-G1 | Switch 24 | |
| | | US24P250 | usw | US-24-250W | Switch 24 PoE (250 W) | |
| | | US24P500 | usw | US-24-500W | Switch 24 PoE (500 W) | |
| | | US24PL2 | usw | US-L2-24-PoE | Switch 24 PoE | |
| | | US24PRO | usw | USW-Pro-24-PoE | Switch Pro 24 PoE | |
| | | US24PRO2 | usw | USW-Pro-24 | Switch Pro 24 | |
| | | US48 | usw | US-48-G1 | Switch 48 | |
| | | US48P500 | usw | US-48-500W | Switch 48 PoE (500 W) | |
| | | US48P750 | usw | US-48-750W | Switch 48 PoE (750 W) | |
| | | US48PL2 | usw | US-L2-48-PoE | Switch 48 PoE | |
| | | US48PRO | usw | USW-Pro-48-PoE | Switch Pro 48 PoE | |
| | | US48PRO2 | usw | USW-Pro-48 | Switch Pro 48 | |
| | | US624P | usw | USW-Enterprise-24-PoE | Switch Enterprise 24 PoE | |
| | | US648P | usw | USW-Enterprise-48-PoE | Switch Enterprise 48 PoE | |
| | | US68P | usw | USW-Enterprise-8-PoE | Switch Enterprise 8 PoE | |
| | | US6XG150 | usw | US-XG-6PoE | Switch 6 XG PoE | |
| | | US8 | usw | US-8 | Switch 8 | |
| | | US8P150 | usw | US-8-150W | Switch 8 PoE (150 W) | |
| | | US8P60 | usw | US-8-60W | Switch 8 (60 W) | |
| | | USAGGPRO | usw | USW-Pro-Aggregation | Switch Aggregation Pro | |
| | | USC8 | usw | US-8 | Switch 8 | |
| | | USC8P150 | usw | US-8-150W | Switch 8 PoE (150 W) | |
| | | USC8P450 | usw | USW-Industrial | Switch Industrial | |
| | | USC8P60 | usw | US-8-60W | Switch 8 (60 W) | |
| | | USF5P | usw | USW-Flex | Switch Flex | |
| | | USFXG | usw | USW-Flex-XG | Switch Flex XG | |
| | | USL16LP | usw | USW-Lite-16-PoE | Switch Lite 16 PoE | |
| | | USL16P | usw | USW-16-PoE | Switch 16 PoE | |
| | | USL24 | usw | USW-24-G2 | Switch 24 | |
| | | USL24P | usw | USW-24-PoE | Switch 24 PoE | |
| | | USL48 | usw | USW-48-G2 | Switch 48 | |
| | | USL48P | usw | USW-48-PoE | Switch 48 PoE | |
| | | USL8A | usw | USW-Aggregation | Switch Aggregation | |
| | | USL8LP | usw | USW-Lite-8-PoE | Switch Lite 8 PoE | |
| | | USL8MP | usw | USW-Mission-Critical | Switch Mission Critical | |
| | | USMINI | usw | USW-Flex-Mini | Switch Flex Mini | |
| | | USPPDUP | usw | USP-PDU-Pro | SmartPower PDU Pro | |
| | | USPRPS | usw | USP-RPS | SmartPower Redundant Power System | |
| | | USXG | usw | US-16-XG | Switch XG 16 | |
| | | USXG24 | usw | USW-EnterpriseXG-24 | Switch Enterprise XG 24 | |
| | | UXBSDM | uap | UWB-XG-BK | WiFi BaseStation XG | |
| | | UXGPRO | uxg | UXG-Pro | Next-Generation Gateway Pro | |
| | | UXSDM | uap | UWB-XG | WiFi BaseStation XG | |
| | | p2N | uap | PICOM2HP | PicoStation M2 HP | |
| |
| ^ DPI Category Code ^ Name ^ | ^ DPI Category Code ^ Name ^ |
| # Configured port forwards and uPNP - transfer bytes is listed but doesn't appear populated | # Configured port forwards and uPNP - transfer bytes is listed but doesn't appear populated |
| api/s/{site}/stat/portforward | api/s/{site}/stat/portforward |
| | |
| | # Update User (User are the clients) |
| | api/s/{site}/upd/user/{UserId} |
| | you can get the users and the userid from "/api/s/{SiteId}/stat/alluser" (All Clients) or "/api/s/{SiteId}/stat/sta" (Active Clients) which contains the client id (_id). |
| | example: change name of user with clientid 5aca464bb79fc60200460394 to 'test-raw': |
| | ${curl_cmd} --data "json={'name':'test-raw'}" $baseurl/api/s/$site/upd/user/5aca464bb79fc60200460394 |
| | |
| | # Get Hotspot Configuration |
| | guest/s/{site}/hotspotconfig |
| | You will get in "auth" the value "none" if it is not activated, if it is activated you will get for exemple "hotspot" and many other values on the design of the page. |
| | |
| | # Get Hotspot Packages |
| | guest/s/{site}/hotspotpackages |
| | ?? |
| | |
| | # Get trafficrules |
| | v2/api/site/{site}/trafficrules |
| | also possible to add new rule with a POST request. |
| | |
| | # Edit trafficrules |
| | v2/api/site/{site}/trafficrules/{id}/ |
| | PUT or DELETE request to update or delete traffic rule |
| | GET is not allowed on specific trafficrules. |
| | With PUT the result code is 201 and not 200 for successful change. |
| |
| |