{{define "content"}} {{with .Data}}

Using the API

Everything the MCP server offers, over plain HTTP. Base address {{.Base}}; the machine-readable description is /api/openapi.json (OpenAPI 3.1, no token needed).

Every call needs a token on the API access page, sent as Authorization: Bearer rtr_…. A read token may use the read operations; a change token also the others. Changes to the settings are saved, never applied: you review them under Changes and apply them yourself.

Errors are JSON, {"error": "…"}, with the status 400 (refused or a bad argument), 401 (no or an expired token), 403 (the token's access is too low), 409 (stale ETag) or 500. Results are JSON, except the pending changes and the journal, which are plain text.{{if .HasOptions}} GET /api/v1/options lists every router option with its type, default and description: what settings may contain.{{end}}

Examples use -k because the certificate is self-signed unless you set up a certificate; put your token in $TOKEN.

{{range .Ops}}

{{.Method}} {{.Path}} {{.Summary}}

Access: {{.Scope}}

{{.Description}}

{{if .Params}}
{{range .Params}}{{end}}
ParameterTypeDescription
{{.Name}}{{.Type}}{{if .Required}}required{{end}}{{.Description}}
{{end}} {{with .Body}}

Body: {{.}}

{{end}}
{{.Curl}}
{{end}}

Settings areas

The settings are a tree, and every part of it has its own path below /api/v1/settings: router/firewall, router/lans/lan (one LAN, by its name), router/dns/hosts, system, down to a single option like router/wan/interface (lists are replaced whole; their elements have no paths). The OpenAPI document describes each with the type of its value.

curl -sk -H "Authorization: Bearer $TOKEN" https://{{.Host}}/api/v1/settings/router/dns
curl -sk -X PUT -H "Authorization: Bearer $TOKEN" -H 'If-Match: "ETAG"' \
  -d '{"domain":"home.example.org","dynamicLeases":true}' https://{{.Host}}/api/v1/settings/router/dns
{{range .Areas}}

{{.Path}}

{{range .Options}}{{end}}
OptionTypeDefaultDescription
{{.Name}}{{.Type}}{{with .Default}}{{.}}{{end}}{{.Description}}

<name> is the key of an entry in a map, * an element of a list.

{{end}} {{end}} {{end}}