# UniFi Site Manager API vs local Network API

## Lesson

The Site Manager API key from `api.ui.com` is useful for high-level cloud inventory, but it does not expose enough detail for switch-port diagnostics or PoE port actions.

## Site Manager API can provide

Endpoints such as:

```text
GET https://api.ui.com/v1/sites
GET https://api.ui.com/ea/sites
GET https://api.ui.com/ea/hosts
GET https://api.ui.com/ea/devices
```

Useful for:

- host/site IDs
- gateway names and WAN IPs
- high-level device inventory
- online/offline counts
- rough internet health summaries

Example fields seen:

```text
siteId
hostId
hostName
ipAddress
meta.desc
statistics.counts
statistics.internetIssues
```

## Site Manager API was insufficient for

- switch port stats
- CRC/FCS errors
- packet drops
- port up/down events
- PoE state/history
- client history by MAC/IP
- approval-gated PoE power cycle

## Local Network API is required for port work

For workflows like a Yealink W70 cordless base on a UniFi switch port periodically producing static, use the local UniFi Network API key created inside each console:

```text
UniFi Network → Integrations → Network API → Create API Key
```

The port action endpoint documented by UniFi has this shape:

```text
POST /v1/sites/{siteId}/devices/{deviceId}/interfaces/ports/{portIdx}/actions
```

## Liberty / GLC identifiers discovered

Liberty:

```text
Host: Liberty-UDM-Pro
Host ID: D8B3702867A1000000000770A2860000000007CBEC34000000006437A55B:1003909054
Site ID: 66cfc43699ec0d7200188ed3
WAN/IP: 108.175.202.88
Switch: USW-24-PoE
Switch MAC: E4:38:83:94:66:E3
Switch IP: 10.1.0.5
```

GLC:

```text
Host: GLC UDM Pro
Host ID: AC8BA96EDB4F0000000007153E2D00000000076AA09A0000000063974676:10670668
Site ID: 66770d7ed634742ade16b848
WAN/IP: 75.62.181.131
```

## Safe workflow for port power-cycling

1. Read-only first: identify switch, port, client MAC/IP, and current counters.
2. Correlate incident time with port errors/flaps and WAN latency.
3. Do not power-cycle without explicit approval.
4. If approved, execute the port action and verify link/client recovery.
5. Keep a small incident log for repeated port/phone failures.
