Go + HTTPS · LAN-only · RBAC admin/operator/viewer
The API is the console,
underneath.
Everything the management UI does goes through the same /api/v1 surface. This page documents the auth model, the RBAC matrix, health semantics, and every registered route — verified against the Preview 128 source tree.
Basics
- Base URL:
https://<lan-ip>/(default443;https://<lan-ip>:8443also works). HTTP on80/8080redirects to HTTPS — as does a mistypedhttp://<lan-ip>:8443. - Management is LAN-only. The listener binds to the LAN interface after setup (
SO_BINDTODEVICE). Do not expose it to the WAN — use a VPN for remote access. - Transport: TLS by default. First boot uses a self-signed certificate; replace it with one from your local CA or import a PEM pair (administrator manual · TLS).
curlexamples below use-kto tolerate that self-signed default — remove-konce a trusted certificate is installed. - Format: JSON in, JSON out. Errors are shaped
{"error": "…"}with a non-2xx status. Collection writes useETag/If-Matchconcurrency control, an apply lock, and file snapshot/rollback underneath. - Reconnect hint: writes that touch network state return
X-ASCS-Reconnect: 1so clients know to re-establish sessions. - Audit: every mutating request is appended to the audit log with actor, client IP, action, and result — read-only at
/api/v1/audit.
Authentication
Two equivalent ways to authenticate, plus a first-boot setup path:
| Mechanism | How | Notes |
|---|---|---|
| Session cookie | POST /api/v1/auth/login with username/password; cookie set for subsequent requests. | Passwords are Argon2id (legacy hashes migrate to PBKDF2-on-login). Login is rate-limited: 5 failures per 5 minutes per source IP. |
| API key | Authorization: Bearer <key-secret> | Scoped, expirable, revocable, rotatable keys. The secret is shown once at creation — store it like a password. Keys authenticate as key:<id>; their role is derived from their scopes. |
| First-boot setup | Tokenless setup bound to the first enabled LAN interface; optional setup code from the console. | Usable only before setup completes: /api/v1/system, /api/v1/config, /api/v1/setup/status, /api/v1/setup/apply. |
# 1) Log in and keep the session cookie
curl -sk -c jar.txt -X POST https://10.10.0.1/api/v1/auth/login \
-H 'Content-Type: application/json' \
-d '{"username":"admin","password":"…"}'
# 2) Use the session
curl -sk -b jar.txt https://10.10.0.1/api/v1/auth/me
# 3) Or use an API key
curl -sk https://10.10.0.1/api/v1/stats \
-H 'Authorization: Bearer ascs_…'
RBAC matrix
Roles: admin, operator, viewer. The matrix below is enforced server-side — hidden buttons are not the security boundary.
| Capability | viewer | operator | admin |
|---|---|---|---|
Read any object (GET/HEAD/OPTIONS) | ✓ | ✓ | ✓ |
| Create/update/delete network objects (rules, NAT, DHCP, aliases, schedules, routes, reservations, filters, interfaces, uplinks, segments, bridges, public IPs, source-NATs, policy routes) | — | ✓ | ✓ |
PUT /api/v1/config (raw config replace) | — | — | ✓ |
POST /api/v1/setup/apply | — | — | ✓ |
Users (/api/v1/users…) | — | — | ✓ |
API keys (/api/v1/api-keys…) | — | — | ✓ |
Certificates & local CA (/api/v1/certificates…) | — | — | ✓ |
PUT /api/v1/system/timezone · PUT /api/v1/system/power · POST /api/v1/system/factory-defaults | — | — | ✓ |
Diagnostics ping/traceroute (POST /api/v1/diagnostics/ping, …/traceroute) | — | — | ✓ |
| Diagnostics read, firewall-test, capture, bundle | ✓ (read) | ✓ | ✓ |
| Apps: list, logs, install/start/stop/uninstall/update actions | — | ✓ | ✓ |
| Update center: status (read) / apply / rollback | read | apply/rollback | apply/rollback |
| Own password change / logout | ✓ | ✓ | ✓ |
API-key scopes map to a role via scopeRole; a read-only scope yields a viewer-equivalent key. Rotate keys with POST /api/v1/api-keys/{id}/rotate; revoke with DELETE /api/v1/api-keys/{id}.
Health semantics (GET /api/v1/health)
Public, no auth — safe for monitoring. 200 means the management plane and dataplane prerequisites are present, not merely that the Go process is up.
$ curl -sk https://10.10.0.1/api/v1/health
{
"status": "ok",
"checks": {
"nftables": "ok",
"nat": "ok",
"default_route": "ok",
"dnsmasq": "ok",
"systemd-networkd": "ok"
}
}
If any check fails the endpoint returns 503 with "status":"degraded" and the failing keys set to missing / not active / not installed. A degraded result with default_route: missing means the WAN is not providing a default route — reachable UI, dead uplink. Wire this into your monitoring; details in the administrator manual.
Route index
Every route registered in Preview 128. Collection routes support list/create/get/update/delete unless marked read-only. Network-affecting writes return X-ASCS-Reconnect: 1.
Auth & session
| Method & path | Purpose |
|---|---|
POST /api/v1/auth/login | Session login (rate-limited). |
POST /api/v1/auth/logout | End the session. |
GET /api/v1/auth/status | Auth subsystem status (public). |
GET /api/v1/auth/me | Current user and role. |
POST /api/v1/auth/password | Change own password. |
Setup & system
| Method & path | Purpose |
|---|---|
GET /api/v1/setup/status | First-boot claim status. |
POST /api/v1/setup/apply | Apply first-boot setup (admin). |
GET /api/v1/system | System identity/version. |
GET /api/v1/system/hardware | Hardware profile (NICs, boot device, BIOS info). |
GET/PUT /api/v1/system/timezone | Timezone (PUT = admin). |
GET/PUT /api/v1/system/power | Power profile, e.g. power-on-after-AC-loss (PUT = admin). |
GET/PUT /api/v1/system/ssh | Key-only SSH enable/restrict; disabling clears the authorized keys. |
POST /api/v1/system/reboot | Reboot the appliance. |
POST /api/v1/system/factory-defaults | Factory defaults (admin; destructive). |
Users & API keys (admin)
| Method & path | Purpose |
|---|---|
GET/POST /api/v1/users · GET/PUT/DELETE /api/v1/users/{id} | Named admin/operator/viewer accounts. |
GET/POST /api/v1/api-keys | List / create scoped, expirable keys (secret shown once). |
POST /api/v1/api-keys/{id}/rotate | Rotate a key’s secret. |
DELETE /api/v1/api-keys/{id} | Revoke a key. |
Config collections — CRUD (list/create/get/update/delete)
| Collection | Path | What it holds |
|---|---|---|
| Uplinks | /api/v1/uplinks | WAN interfaces: DHCP/static/PPPoE, gateway, metric, healthCheck/healthTarget, MSS clamp. |
| Segments | /api/v1/segments | LAN/OPT: interface, VLAN, subnet, DHCPv4 ranges/leases, DHCPv6 mode, IPv6 prefix hints, MAC, aliases. |
| Public IPs | /api/v1/public-ips | Routed/assigned public addresses; explicit Unassigned / Avail filter in the UI. |
| Bridges | /api/v1/bridges | Bridge groups. |
| Port forwards | /api/v1/port-forwards | DNAT: shared IP, ports (1–65535, !5000), target[:port], protocol, egress. Catch-all forwards are the 1:1 NAT building block. |
| IPv4 rules | /api/v1/ipv4-rules | Ordered policy: action, interface, source/destination, ports, alias/schedule-aware. |
| IPv6 rules | /api/v1/ipv6-rules | The IPv6 counterpart. |
| Source NATs | /api/v1/source-nats | Outbound source rewriting per interface. |
| Policy routes | /api/v1/policy-routes | Source-based next-hop selection with metric — the multi-WAN scalpel. |
| Aliases | /api/v1/aliases | Host / Network / Port aliases. |
| Schedules | /api/v1/schedules | Time windows for rules. |
| Static routes | /api/v1/static-routes | Static destinations via chosen interface/gateway. |
| Domain filters | /api/v1/domain-filters | DNS domain blocking (domain and subdomains) via dnsmasq. |
| DHCP reservations | /api/v1/dhcp-reservations (+ /bulk) | MAC → address pinning; bulk import. |
Audit (read-only)
GET /api/v1/audit · GET /api/v1/audit/{id} — append-only in the UI; every authenticated mutation lands here with actor, IP, action, target, and result. Filter here before you touch anything else when something changed overnight.
Monitoring
| Method & path | Purpose |
|---|---|
GET /api/v1/stats | Interface rates, load, memory, conntrack and session counts. |
GET /api/v1/wan-health | Per-uplink health probe results and failover state. |
GET /api/v1/neighbors | ARP/NDP neighbor table — find what’s on the wire. |
GET /api/v1/dhcp/leases | Active DHCPv4 leases (pairs with reservations). |
Diagnostics
| Method & path | Purpose |
|---|---|
GET /api/v1/diagnostics | Diagnostics overview. |
GET /api/v1/diagnostics/bundle | Redacted, downloadable support bundle from Settings. |
POST /api/v1/diagnostics/ping | Ping (admin). |
POST /api/v1/diagnostics/traceroute | Traceroute (admin). |
POST /api/v1/diagnostics/firewall-test | Explain this flow — IPv4 forward-chain simulator with rule trace, alias/schedule awareness, conntrack states, LAN→WAN forwarding and DNAT acceptance. |
POST /api/v1/diagnostics/capture | Bounded packet capture (pcap). |
Update center & certificates
| Method & path | Purpose |
|---|---|
GET /api/v1/update/status | Current/previous slot, application version, health. Read-only. |
POST /api/v1/update/apply | Apply a signed update; health supervision auto-rolls-back an unhealthy slot. |
POST /api/v1/update/rollback | Roll back to the previous application slot. |
GET /api/v1/certificates | List issued/imported certificates. |
POST /api/v1/certificates/ca | Create/manage the local CA (ECDSA P-256). |
POST /api/v1/certificates · POST /api/v1/certificates/import | Issue with DNS/IP SANs · import PEM certificate/key. |
GET /api/v1/certificates/{id}/download | Download certificate PEM (keys are root-only, never exportable via API). |
POST /api/v1/certificates/{id}/management · DELETE /api/v1/certificates/management | Select a cert for the management listener · one-click revert to the generated cert. |
DELETE /api/v1/certificates/{id} | Delete a certificate. |
Traffic shaping, interfaces, cloud I/O, apps
| Method & path | Purpose |
|---|---|
GET/PUT /api/v1/traffic-shaping | WAN upload/download limits; Preview 128 adds granular HTB classes + flower filters (per interface, IP/CIDR, TCP/UDP port, direction, rate, ceiling, priority). |
POST /api/v1/interfaces/remap | Remap logical roles onto interfaces (e.g. after restore from another box). |
PATCH /api/v1/config/metadata | Patch config metadata without a full replace. |
GET/PUT /api/v1/config | Whole-config read/replace — PUT is admin-only. GET doubles as the JSON export the appliance uses for configuration backups. |
GET/POST /api/v1/cloud-io/interfaces · DELETE …/{name} | Cloud-side virtual NIC management (ASCS Cloud VPS edition). |
GET /api/v1/apps · GET /api/v1/apps/{id}/logs · POST /api/v1/apps/{id}/{action} | App Store: catalog with runtime status, logs, install/start/stop/uninstall/update-slot actions (Docker runtime). |
Worked examples
# Create an alias for three management hosts
curl -sk -b jar.txt -X POST https://10.10.0.1/api/v1/aliases \
-H 'Content-Type: application/json' \
-d '{"name":"mgmt-hosts","type":"Host","value":"10.10.0.11,10.10.0.12,10.10.0.13","description":"admin stations","state":"Active"}'
# List IPv4 rules, ordered
curl -sk -b jar.txt https://10.10.0.1/api/v1/ipv4-rules | jq '.[] | {id,action,interface,source,destination,dport}'
# Add a port forward: public 8080 -> internal 10.10.0.20:80
curl -sk -b jar.txt -X POST https://10.10.0.1/api/v1/port-forwards \
-H 'Content-Type: application/json' \
-d '{"sharedIp":"<WAN-IP>","ports":"8080","target":"10.10.0.20","targetPort":"80","protocol":"TCP","state":"Active"}'
# Ask why a flow would be dropped
curl -sk -b jar.txt -X POST https://10.10.0.1/api/v1/diagnostics/firewall-test \
-H 'Content-Type: application/json' \
-d '{"src":"10.10.0.50","dst":"203.0.113.10","proto":"tcp","dport":443}'
# Pull a JSON configuration backup yourself
curl -sk -b jar.txt https://10.10.0.1/api/v1/config -o backup-$(date +%F).json
# (preferred: the UI’s Backups & Recovery page — see /storage.html)
# Check health the way monitoring would
curl -sk -w '\nHTTP %{http_code}\n' https://10.10.0.1/api/v1/health
The contract & CI
The Go API is covered by an OpenAPI 3.1 contract and a JSON Schema in the source tree (specs/openapi.yaml, specs/config.schema.json). CI enforces: route-versus-contract conformance, schema validation, Go tests/vet/staticcheck, JSON Schema and OpenAPI validation, ESLint/JS syntax checks for the console, and a disposable TLS/auth/API smoke test. The same checks gate the ISO. If you are building tooling against this API, this page plus those two files are the source of truth — and support@ascsonoway.com for anything ambiguous.
curl + jq are enough for everything above. RFC 9110 covers the HTTP semantics (ETag/If-Match are §13.1.1). For UI behaviour with live data, see the real console captures; for update/rollback flows see the administrator manual.
