# Proxy Router API: Automate Your Router

> For AI tools: this is the Markdown copy of https://xproxy.io/document/proxy-router-api. Every XProxy guide has one at its URL + `.md`; the index of all guides is https://xproxy.io/llms.txt.

Sign in, give proxies to many devices, pause devices, set routing rules and read the leak monitor from your own scripts with the Proxy Router REST API.

Everything you can do in the Proxy Router dashboard you can also do from your own scripts with the REST API. Use it to give proxies to many devices, read the leak monitor, or change rules, behind the same dashboard password.

**You need:** the dashboard password, a computer that is plugged into the router and has no proxy (or is on the [admin access list](https://xproxy.io/document/proxy-router-protection#admin-access)), and the router's address. The API listens on port 8080: `http://192.168.1.1:8080`.

## How do I call it?

1. Sign in with `POST /auth/login`. The answer sets a session cookie.
2. Send that cookie with every other call. It stays valid until you have been away for 12 hours.
3. Send every POST as JSON, with the header `Content-Type: application/json`. A body of `{}` is fine when there is nothing to send.

```
# 1. sign in once and keep the session cookie
curl -c rp.cookies -X POST http://192.168.1.1:8080/auth/login \
  -H "Content-Type: application/json" \
  -d '{"password":"your-dashboard-password"}'

# 2. send the cookie with every other call
curl -b rp.cookies http://192.168.1.1:8080/clients
```

## The rules

- **Only the router's own address works.** Use the router's IP address or its name. Anything else gets 403.
- **Browsers only from the dashboard.** Other web pages cannot call the API, even on your network.
- **Devices with a proxy cannot reach it**: the router is invisible to them. Call it from a device without a proxy or one on the admin access list.
- **Proxy passwords are never returned.** They show as `••••`. Sending a proxy back with `••••` keeps the saved password only if the host, port and user are unchanged; otherwise you get 400 and must send the password again.
- **One restart per change.** Changing proxies or rules restarts the proxy service for all devices. Use the bulk calls for many devices at once.
- Calls marked **license** need an active license.

## The API page in the dashboard

The **API** page of the dashboard lists every call, with its parameters, a ready curl command and a sample answer. Click a call to open it, and use **Copy**. **Copy all as curl** copies every call at once.

## Examples

### Give a device a proxy

```
curl -b rp.cookies -X POST http://192.168.1.1:8080/client_proxy \
  -H "Content-Type: application/json" \
  -d '{"ip":"192.168.1.101","proxy":"socks5://user:pass@1.2.3.4:1080","proxy_type":"SOCKS5","name":"Phone 01","remote_fakedns":true}'
```

Fields: `ip` (the device's address on the router), `proxy` (in any of the [usual formats](https://xproxy.io/document/proxy-router-devices#proxy-formats); an empty string clears it), `proxy_type` (`SOCKS5` or `HTTP`), `name` (a label) and `remote_fakedns` (`true` for FakeDNS, `false` for DoH via proxy). Loopback, link-local, multicast and the router's own addresses are refused with 400.

### Give many devices a proxy at once

```
curl -b rp.cookies -X POST http://192.168.1.1:8080/client_proxy/bulk \
  -H "Content-Type: application/json" \
  -d '[{"ip":"192.168.1.101","proxy":"socks5://user:pass@172.56.21.17:20145","proxy_type":"SOCKS5"},
       {"ip":"192.168.1.102","proxy":"user:pass@174.205.38.18:8080","proxy_type":"HTTP"}]'
```

### Pause a device

```
curl -b rp.cookies -X POST http://192.168.1.1:8080/client_proxy/pause \
  -H "Content-Type: application/json" \
  -d '{"ip":"192.168.1.101"}'
```

Resume it with `/client_proxy/resume` and the same body.

### Set routing rules

```
curl -b rp.cookies -X POST http://192.168.1.1:8080/routing \
  -H "Content-Type: application/json" \
  -d '{"direct":["netgear.com"],"block":["analytics.example.com"],"presets":{"ads":true}}'
```

### Read the leak monitor

```
curl -b rp.cookies http://192.168.1.1:8080/leakmon
```

## All calls

The same list as the dashboard's API page. Every call answers JSON.

### Login

| Call | What it does |
| --- | --- |
| `POST /auth/login` | Sign in with {"password": "..."}. Sets the session cookie. |
| `GET /auth/status` | Whether a password is set and whether this session is signed in. |
| `POST /auth/logout` | End this session. |

### Devices and proxies

| Call | What it does |
| --- | --- |
| `GET /dhcp_clients` | Devices with an address. “online” tells whether the device is connected now. |
| `POST /client/forget` | Forget an offline device: name, proxy, fixed IP and traffic. 409 while it is online. |
| `GET /clients` | The saved settings of every device. Proxy passwords show as ••••. “paused” and “exit_ip” are included. |
| `GET /client_proxy/:ip` **license** | The proxy settings of one device. |
| `POST /client_proxy` **license** | Assign a proxy to a device, or clear it with an empty proxy. |
| `POST /client_proxy/bulk` **license** | Assign or clear many devices with one restart of the proxy service. Every item is checked first. |
| `POST /client_proxy/pause` **license** | Pause a device’s proxy: it keeps its proxy and settings but has no internet until resumed. |
| `POST /client_proxy/resume` **license** | Resume a paused device with exactly the proxy it had. |
| `POST /client_proxy/pause/bulk` **license** | Pause many devices (at most 256) with one restart. |
| `POST /client_proxy/resume/bulk` **license** | Resume many paused devices with one restart. |
| `POST /client/bind_ip_mac` | Fix or release a device’s IP (the DHCP static lease). |
| `GET /client/dhcp_reservations` | The fixed IPs. |
| `GET /clients/traffic` | Total traffic per device. |
| `POST /clients/traffic/reset` | Reset the traffic of one device, or of all devices when no ip is sent. |

### Proxy testing

| Call | What it does |
| --- | --- |
| `POST /proxy/test` | Check a proxy: alive, exit IP, delay and place. |
| `POST /proxy/speedtest` | Download and upload speed through a proxy (30 to 60 seconds). |

### Protection

| Call | What it does |
| --- | --- |
| `GET /killswitch` | The kill switch: protected devices, the block-devices-without-a-proxy switch, the direct-access list and packets stopped. |
| `POST /killswitch` | Turn Block devices without a proxy on or off ({"block_unassigned": true}). |
| `POST /killswitch/direct` | Add or remove a device on the direct-access list. |
| `GET /leakmon` | The leak monitor: status and blocked attempts per device and kind. |
| `GET /leakmon/:ip` | One device, with 24 hourly buckets. |

### Routing rules

| Call | What it does |
| --- | --- |
| `GET /routing` | The router-wide Go direct and Block lists, the presets and the memory. |
| `POST /routing` | Save and apply the router-wide rules. A bad line makes the whole call fail with 400 and nothing changes. |
| `GET /routing/device/:ip` | The rules of one device. |
| `POST /routing/device/:ip` | Save one device’s rules. Empty lists and no presets remove them. |

### Logs

| Call | What it does |
| --- | --- |
| `GET /logs/leaks` | Blocked attempts, newest first (filters: ip, category, since, limit). |
| `GET /logs/connections` | Recorded connections, while the connection log is on. |
| `GET /logs/connections/settings` | Whether the connection log is on. |
| `POST /logs/connections/settings` | Turn the connection log on or off. Restarts the proxy service. |
| `GET /logs/system` | The newest lines of the router log. Passwords masked. |

### Network

| Call | What it does |
| --- | --- |
| `GET /network/wan` | Internet status: link, address, gateway, DNS, uptime, public IP. |
| `GET /network/lan` | Router IP, mask, device range and lease time. |
| `POST /network/lan` | Change them. A new router IP disconnects every device. |

### System and updates

| Call | What it does |
| --- | --- |
| `GET /health` | Is the router service up. Needs no login. |
| `GET /linux_resource` | CPU %, RAM %, uptime in hours and the version. |
| `GET /license/info` | License status, customer, expiry and days left. |
| `POST /license/save` | Save a license key. |
| `POST /license/verify` | Check the license now. |
| `POST /system/restart` | Restart the proxy service. |
| `POST /system/reboot` | Reboot the router. |
| `GET /system/version` | The installed version and whether a previous one can be restored. |
| `GET /system/update/check` **license** | The latest version. |
| `POST /system/update/apply` **license** | Install the latest version, or a specific one. |
| `GET /system/update/status` | Update progress. |
| `POST /system/update/rollback` **license** | Restore the previous version. |

## Error codes

| Code | What it means |
| --- | --- |
| **401** | No session, or it ended. Sign in again with /auth/login. |
| **403** | The address you used is not the router’s own, or a valid license is required. |
| **415** | A POST was not sent as Content-Type: application/json. |
| **429** | Too many wrong passwords from your address (wait 5 minutes), or too many logins at once. |
| **400** | A field is wrong. The answer names it, and the router changed nothing. |
| **409** | The action does not fit the state, for example forgetting a device that is online. |

## FAQ

### I get 403 on every call

Use the router's own address (for example `192.168.1.1`), not a name your computer made up. If you reach the router through a VPN or a host name, ask [support](https://xproxy.io/document/remote-support) to allow that name.

### I get 401

Your session ended or you did not send the cookie. Sign in again with `/auth/login` and send the cookie with `-b rp.cookies`.

## What next?

Everything the API does has a page in the dashboard.

[Devices →](https://xproxy.io/document/proxy-router-devices) [System →](https://xproxy.io/document/proxy-router-system)

---

Source: https://xproxy.io/document/proxy-router-api
