openwrt-iac / uapi / docs / 4.0.1 / Operations

Operations

"Success" means exit 0, not runtime convergence

A 2xx response to a write means: validate OK, and, when the write changed uci, uci commit OK and the init script's reload action exited 0. A write that changed nothing commits and reloads nothing, and says so with X-Reload-Status: no_reload. It does NOT mean the daemon has finished re-converging.

The most dangerous case is network/interfaces: a write that produces a config netifd later rejects (bad proto, missing dep, conflicting addresses) can drop the management connection. uapi only sees the init script's exit code; netifd's runtime convergence happens after, in the background.

Two signals worth wiring into your automation:

docs/errors.md § Response headers lists every value of both headers. docs/architecture.md § Transaction recipe, steps 0 and 6, has the rules that decide which daemons a write reloads and how uapi checks them. What they mean for an operator:

A write to one package that fails and restores takes at most 20 s of reloads, 2 s of the unbound watch, 10 s of dnsmasq --test per dnsmasq instance and the 1 s of the dnsmasq respawn check after the reloads of the write and again after those of the restore, and up to 5 s of the restore waiting for libuci's flock: 51 s with one dnsmasq instance, inside uhttpd's default script_timeout of 60 s. The kernel apply and the reconcile of the restore also wait for netifd to restart a wireguard interface, 8 s each: a write of the network package stays inside 60 s, and a batch that also writes dhcp, with every reload at its bound, can pass it. The stop and the start of dnsmasq add nothing to these bounds. They run only when 10 s of the 20 s are left, each step ends within the 20 s, and a check that ran before them ran inside the 20 s too. A write of one package that runs them answers within 20 s of its first reload, since nothing after them can fail and restore. With the default config limits, the worst write that runs them is a batch that also writes network: 20 s of reloads, checks and recovery, 8 s of the kernel apply, and when that fails, 13 s of the checks after the restore and 8 s of the reconcile, 49 s. A POST /uapi/batch restore adds up to 5 s of flock wait for each further package that it writes back, and the wg set of a kernel apply or reconcile has no time bound: wg retries an endpoint name whose lookup fails for a time. busybox's nslookup runs under the lock of network too, about 5 s at most for each name server of /etc/resolv.conf, once for each peer with an endpoint name in the kernel apply and in the reconcile of the restore. A feed write waits for apk update up to reload_budget_s, but apk add and apk del have no total bound (docs/non-uci-state.md). uapi does not read script_timeout. Set it lower, through uhttpd/instances or otherwise, and uhttpd can kill such a request before its restore or its answer: the client gets a 502, and uci keeps whatever the write had reached. Keep it at 60 s or above on a router that uapi manages.

A LuCI save or a uci commit in a shell takes no uapi lock. When such a commit lands in the package while uapi reloads it, and the reload then fails, uapi leaves the package as that writer left it, and answers 500 reload_failed_unrecovered, whose restore_error names the package. The daemon keeps what the failed reload gave it, so check the package and reload it by hand. In a POST /uapi/batch, uapi restores the other packages. docs/architecture.md § Transaction recipe, step 8, has the details.

For high-stakes writes (the management interface, firewall defaults, uhttpd itself) verify convergence out-of-band: poll the runtime block on the resource you just modified, check ubus state, or simply ping the box and confirm reachability. uapi cannot do this for you; the init script doesn't know either.

A commit-confirmed mode, which reverts a write that no client confirms, would close this gap. It is deferred, and docs/commit-confirm.md says why.

NTP

Audit logs and request IDs both encode timestamps. If the router's clock is wrong, those timestamps are wrong, and correlating events across machines breaks.

OpenWrt ships an SNTP client (sysntpd) enabled by default. Confirm it is running and has synced:

/etc/init.d/sysntpd status
date

If the router has no internet during boot (or you ship a different time source), point sysntpd at it via uci set system.ntp.server=....

Persistent syslog

By default logd keeps the log ring in memory (default size 16 KiB) and loses it on reboot. For any router serving uapi in production, configure persistent logging:

uci set system.@system[0].log_file='/var/log/messages'
uci set system.@system[0].log_size='2048'      # KiB; tune to flash health
uci commit system
/etc/init.d/log restart

This writes the in-memory ring through to flash, surviving reboots. Mind flash wear: 2-4 MiB is typical; full-time access logging is not appropriate for flash without external storage.

For longer retention, mount a USB stick or remote filesystem and point log_file there.

Forwarding audit logs off-box

uapi emits one syslog line per successful write under the daemon.notice priority. Forward to a central collector for tamper-resistant audit trails:

uci set system.@system[0].log_ip='10.0.0.5'        # syslog collector IP
uci set system.@system[0].log_port='514'
uci set system.@system[0].log_proto='udp'          # or 'tcp' for reliability
uci commit system
/etc/init.d/log restart

The receiving collector (rsyslog, syslog-ng, Loki, Splunk, etc.) can filter on the syslog tag uapi, which a line shows as uapi[<pid>]:, to isolate API audit events.

Log categories

Category syslog severity Default Triggers
AUDIT NOTICE on Successful writes (POST/PUT/PATCH/DELETE 2xx)
ERROR WARN / ERR on Auth failures (401/403), all 5xx
ACCESS INFO off Every request (non-/healthz)
DEBUG DEBUG off Per-ubus-call tracing

/healthz is excluded from all categories so monitoring traffic does not drown out the audit trail. Non-auth 4xx responses (404, 405, 409, 422, 423) are not logged: the client receives the error directly and there is no operator-actionable signal in volume.

ACCESS and DEBUG are off by default. Turn them on in /etc/config/uapi:

config logging
    option access '1'   # log every request (INFO)
    option debug '1'    # per-ubus-call tracing (DEBUG)

Leave these off unless you're debugging. They are noisy and will fill the in-memory ring quickly.

Log line format

Plain text, fixed field order, syslog-native (chosen over JSON-per-line because logread is the primary consumer):

uapi[<pid>]: <request_id> <token_name|-> <category> <code|-> <method> <path> <status> [<duration_ms>ms]

A POST /uapi/batch logs one line for the whole request. The id of a sub-request, <request_id>.<index>, shows only in the headers of its entry in the 207 results and in recent_errors of /uapi/diagnostics.

Sample syslog output

# AUDIT: a successful POST that created a firewall rule
uapi[1234]: 01HX1234567890ABCDEFGHJKMN tf-prod AUDIT - POST /firewall/rules 200 [42ms]

# ERROR (5xx)
uapi[1234]: 01HX234567890ABCDEFGHJKMNN tf-prod ERROR reload_failed_restored PUT /network/interfaces/wan 500 [3120ms]

# WARN (auth failure)
uapi[1234]: 01HX34567890ABCDEFGHJKMNNN - WARN unauthorized GET /system 401 [1ms]

# ACCESS (only when option access '1' is set)
uapi[1234]: 01HX4567890ABCDEFGHJKMNNNN tf-readonly ACCESS - GET /firewall/rules 200 [8ms]

# DEBUG (only when option debug '1' is set; per ubus.call)
uapi[1234]: uapi-bus call system.info args={}

# Internal error from the top-level exception handler
uapi[1234]: uapi-internal 01HX567890ABCDEFGHJKMNNNNN: Type error: ...

# Insecure-bypass marker triggered
uapi[1234]: uapi-insecure-bypass 01HX67890ABCDEFGHJKMNNNNNN GET /system status=200 remote=10.0.2.2

# A request body that missed the read deadline
uapi[1234]: uapi-body-deadline 01HX7890ABCDEFGHJKMNNNNNNN POST /firewall/rules status=400 remote=10.0.2.2

Metrics

GET /api/v4/uapi/metrics returns Prometheus 0.0.4 text. Scope: uapi:metrics:ro (covered by *:ro). Counters and histograms are file-backed under /var/run/uapi-metrics/ (tmpfs - resets on reboot, which is fine for operational counters; aggregate longer-term retention server-side). A package install or upgrade resets them too, and Prometheus reads that as a counter reset.

Series:

Series Type Labels
uapi_requests_total counter method, path (template, e.g. /firewall/rules/:id, or unmatched), status, token_id (- if pre-auth, -retired for tokens that no longer authenticate)
uapi_request_duration_seconds_bucket histogram method, path, le
uapi_request_duration_seconds_count counter method, path
uapi_rate_limit_drops_total counter token_id (-retired as above)
uapi_lock_contention_total counter lock_type
uapi_validate_errors_total counter resource, code

Path templates are normalized (/firewall/rules/:id not the concrete ULID) to keep label cardinality bounded as clients create/destroy resources. A path that no route serves records path="unmatched", and a /raw path keeps its package only when /etc/config holds it. Pre-auth failures (401 before authorize completes) carry token_id="-" so the series row still aggregates. A counter file that holds no count, which a full /tmp could leave behind, is left out of a scrape and starts again at its next increment.

The token_id label is not bounded by the operator, because a client can mint a token per run, as the Terraform provider's ephemeral uapi_token does. A mint and a revoke bound it, over HTTP and with uapi-token, under the lock of the uapi package. Each one folds every series of a token that no longer authenticates (revoked, expired, or deleted from /etc/config/uapi by hand) into the series with the same other labels and token_id="-retired", which no token can be named. The count is added there, and the token's file is deleted once the added count is on disk. A mint, over HTTP and with uapi-token create, folds before its commit, so that a request that uhttpd kills during the fold cannot lose the bearer of a token that it committed. A revoke folds after its commit. The values of token_id are then the tokens that still authenticated at the last mint or revoke, - and -retired, and two kinds that the next mint or revoke folds: a token that revoked itself, as its revoke is recorded after the fold, and a token with a request in flight at its revoke. A client that mints tokens with no expiry and never revokes them keeps every one of them live, and nothing bounds those.

What a scrape sees at a fold: the token's series is gone, and the -retired series of the same method, path and status has grown by the token's count. Folds run one at a time under the lock, so none of them loses an update of -retired. A sum over token_id, such as sum without (token_id) (uapi_requests_total), keeps its value across a fold, with three exceptions:

The requests of a token that a scrape saw once or never, which is usual for a token per run, reach Prometheus through -retired, but only once that series exists. The first fold into a label set creates the -retired series at the token's count, and rate() does not count the first value of a series, so those requests show only in the sum. The cost is with rate(): it reads each later fold as requests at the moment of the fold, so sum(rate(uapi_requests_total[5m])) shows a spike after a mint or a revoke, and counts a second time the part of a token's requests that its own series already showed. For a long-lived token that is revoked, that is most of its history at once. Deleting the series instead would have kept the requests of a short-lived token out of rate(), and made each sum fall at a revoke, which a recording rule that sums before rate() reads as a counter reset.

Sample Prometheus scrape config:

scrape_configs:
  - job_name: uapi
    scrape_interval: 30s
    metrics_path: /api/v4/uapi/metrics
    scheme: https
    authorization:
      type: Bearer
      credentials: <metrics-token>
    static_configs:
      - targets: ['router.example.com']

For broader router-level metrics (load, memory, network counters), the curated prometheus_node_exporter_lua/config resource manages node_exporter's config separately.

Rate limiting

Per-token token-bucket, file-backed at /var/run/uapi-ratelimit/<token>.txt. A token whose name is longer than 63 characters, which only uapi-token can create, has its bucket under the sha256 of its name instead. Defaults: 100 req/s, burst 200 per token. Tune globally via /etc/config/uapi:

config ratelimit
    option rate '500'
    option burst '1000'

No reload needed; the config is read on each authed request.

Per-token overrides win over global: uci set uapi.<token>.rate='10', uci set uapi.<token>.burst='20'. Useful for noisy CI tokens that shouldn't share the global budget.

Exceeded rate returns 429 too_many_requests with Retry-After: <seconds>. The drop is counted in uapi_rate_limit_drops_total{token_id} for operator visibility. Rate limit is a defense-in-depth abuse guard, not a security control on its own; use allowed_cidrs on the token for actual source-IP enforcement.

Request limits

The request bounds are read per request from config limits in /etc/config/uapi; no reload is needed. An option can lower a bound, not raise it: the body is parsed before the bearer check, so a raised body bound would let a request without a token make the parse take hundreds of MB, and the time bounds at their defaults already fill uhttpd's 60 s. The defaults below are the highest accepted values, and the fallback when an option is absent or outside its range:

config limits
    option max_body_bytes '262144'
    option max_body_containers '2000'
    option body_read_s '10'
    option reload_budget_s '20'

GET /uapi/diagnostics reports the effective values under limits.

Diagnostics

GET /api/v4/uapi/diagnostics returns version, uptime, loaded resources, the uapi lock files present under /var/lock, whether uapi uses each state directory under /var/run, the effective request limits, the writes that a killed request left half done, and the last 20 error envelopes. Scope: uapi:diagnostics:ro.

{
  "version": "4.0.0",
  "uptime_seconds": 123456,
  "resources_loaded": ["firewall:rules", "firewall:zones", "..."],
  "lock_state": {
    "global_held": false,
    "per_package": {}
  },
  "state_dirs": {
    "/var/run/uapi-error-ring": true,
    "/var/run/uapi-idempotency": true,
    "/var/run/uapi-interrupted-writes": true,
    "/var/run/uapi-metrics": true,
    "/var/run/uapi-ratelimit": true,
    "/var/run/uapi-token-update": true
  },
  "limits": {
    "max_body_bytes": 262144,
    "max_body_containers": 2000,
    "body_read_s": 10,
    "reload_budget_s": 20
  },
  "interrupted_writes": [],
  "stopped_instances": [],
  "recent_errors": [
    { "ts": 1780510463, "request_id": "01HX...", "code": "validation_failed",
      "status": 422, "method": "POST", "path": "/firewall/rules",
      "message": "Request body failed validation" }
  ],
  "request_id": "01HX..."
}

Finding sections a write would reject (?validate=1)

GET /api/v4/uapi/diagnostics?validate=1 adds a validation sweep: every section of every resource the token may read is run through the same checks as a write, and each section that holds an error is reported with the reason. Each write of such a section answers 422 until it fixes each error, or the change goes through /raw. A validate other than 1 answers 400 bad_request.

{
  "invalid_sections": [
    { "resource": "firewall/rules", "id": "sweepbad", "managed": true,
      "errors": [ { "field": "match.proto", "code": "conflict",
                    "message": "firewall4 keeps a port match only on tcp or udp, so this rule would match the whole protocol instead" } ] }
  ],
  "swept_resources": ["firewall:defaults", "firewall:rules", "..."],
  "skipped_for_scope": []
}

It answers "which sections on this router will stop being accepted" before an upgrade, rather than one 422 at a time during a write. Every section it reports is already broken on the router: the rule above is already matching a whole protocol rather than a port. The sweep is the first time anyone is told.

A value that the platform takes and that uapi does not write is not listed. An interface on a proto that uapi does not model, such as the 6in4 that LuCI writes or the qmi that an LTE router ships, takes a PATCH that leaves proto out, and a wireless/interfaces text option that uci holds as a list reads as an array. Only a write that changes a field to such a value is refused: a write that sends back the value that the section holds, as a PUT of the read does, passes, with two exceptions. A request that names such a proto answers 422 not_in_enum, also when it sends the stored proto, because a PUT would delete the options that its handler reads. So a PUT of the read of such an interface fails, and only a PATCH that leaves proto out can change it and keep its proto. A PUT also answers 422 for the HELPER target that LuCI writes on a firewall rule with its set_helper option, which uapi does not model and a PUT removes.

A validate_new() rule (docs/adding-a-resource.md) is not a break, until the daemon reads the value. Another writer can store a value that such a rule refuses, and the sweep lists it whether the daemon reads it yet or not: the section can be disabled, its mode can leave the field unused, or the radio of an SSID can be disabled. Each error of such a rule has live, which is false when the daemon does not read the value yet. A write of the section is refused for the error either way, because another writer, such as LuCI, can enable the section later.

The sweep also lists a network/wireguard_peers peer that keeps its interface down, because wg refuses the config of the whole interface for one of its values, with code conflict on the field "" and a message that names the interface and the fields. A write of another peer of that interface names it in X-Kernel-Blocked. A write of the peer is refused for each such value that a write refuses, so the write that fixes them clears the finding. An IPv6 link-local host whose %zone names no interface of the router keeps the interface down too, and is not refused, because an interface can exist at one time and not at another, so the peer still takes a write while it holds one.

Three things worth knowing:

One finding shape differs. If a resource's sweep itself fails, the entry reports code: "sweep_failed" with id and managed both null, because there is no section to name:

{ "resource": "firewall/rules", "id": null, "managed": null,
  "errors": [ { "field": "", "code": "sweep_failed", "message": "..." } ] }

That is deliberately a finding rather than a failed request: a resource that could not be checked must not be reported as clean.

dhcp/leases and network/wireguard_kernel_peers are not swept. They are read-only views of daemon state with no validation to run.

The recent_errors ring is best-effort: writes to /var/run/uapi-error-ring/ must never disrupt the actual response, so a disk-full or permission failure simply produces an empty ring rather than a 5xx on the original request. The ring caps at 20 entries (oldest dropped first), and keeps the first 512 bytes of each message, ending a cut one with ...: a 400 for a control character in a body names the key before authentication, so an unclipped message let any client store a body of any size in RAM.

lock_state reports which uapi lock files exist under /var/lock, not which locks are held right now: flock is released when the fd closes and the file itself is never unlinked, so an entry means that package has been written at least once since the lock directory was last cleared.

state_dirs reports each state directory under /var/run, keyed by its path, as uapi finds it. The read of state_dirs creates and changes nothing.

The request that reads it has already changed two of them. Its rate-limit check and its last-used stamp create /var/run/uapi-ratelimit and /var/run/uapi-token-update and narrow them to 0700, so these two read true, or false when uapi cannot own them, and never null. The read of recent_errors that follows creates /var/run/uapi-error-ring, so it reads null only until the first error or the first read of /uapi/diagnostics.

true does not promise free space. On a full tmpfs the rate limiter allows every request, and the idempotency cache, the metrics and the error ring keep no new entry. What false costs while it lasts:

Directory While it reads false
/var/run/uapi-ratelimit The rate limiter allows every request.
/var/run/uapi-idempotency A request with an Idempotency-Key replays nothing, so a retry runs again.
/var/run/uapi-metrics /uapi/metrics records no series.
/var/run/uapi-error-ring recent_errors stays empty.
/var/run/uapi-token-update No request stamps last_used_at.
/var/run/uapi-interrupted-writes A write records nothing, so interrupted_writes cannot list it.

interrupted_writes lists the writes that uhttpd killed after their commit, when the client closed the connection or script_timeout ran out, and the writes that threw after it. Such a write landed in uci with no check, no restore and no answer. Each entry has the pid of the request process, its request_id, the packages, staged (the sections that it wrote, when known), started_at and reload_started. uapi only reports such a write, and neither finishes nor restores it. Check the packages that it names, then reload their daemons or write them again. A record stays until reboot or the next package upgrade.

stopped_instances lists each instance that procd gave up on after too many deaths soon after a start, and will not start again on its own, as {"service": "dnsmasq", "instance": "cfg01411c"}, the names of X-Reload-Stopped. It covers the services that POST /uapi/services/{name}/recover takes. procd lists such an instance not running and without its respawn table. An instance without respawn that ended, such as a one-shot job, looks the same in service list, so the instances of other services are not listed. A write that leaves dnsmasq so answers X-Reload-Status: stopped. The action below, or a start or a reload of the service, starts the instance again. The list is empty when there is none, and also when procd does not answer. Watch it, as the header of a write says it only once.

Starting again a service that procd gave up on

POST /uapi/services/{name}/recover starts again the instances that procd gave up on, for a client that only speaks HTTP. Use it after a write that answers X-Reload-Status: stopped, or when stopped_instances lists an instance. A write that changes nothing does not do it, because it runs no init script.

curl -X POST -H "Authorization: Bearer $TOKEN" \
     https://router/api/v4/uapi/services/dnsmasq/recover
# 200 with body:
# { "service": "dnsmasq", "recovered": [ "cfg01411c" ] }

{name} takes the services that uapi reloads and whose init script sets respawn on every instance that it starts: dnsmasq, lldpd, mwan3, odhcpd, prometheus-node-exporter-lua, snmpd, sysntpd, unbound and vnstat. Another name answers 404 not_found. network, uhttpd and dropbear are not in the list, because the stop acts on the whole service. A stop of network or uhttpd cuts off the request. A stop of dropbear stops the instance that serves the management SSH session, so a start that fails leaves the router without SSH.

The token needs uapi:services:rw, or rw on a domain whose writes reload the service, such as dhcp:rw for dnsmasq, odhcpd and unbound. The spec lists the domains of each service.

When procd gave up on no instance of the service, uapi stops and starts nothing and answers 200 with an empty recovered. So a retry is safe, and a service that runs, that the operator stopped or that the router lacks stays as it is. Otherwise uapi runs /etc/init.d/<name> stop, waits until procd lists no instance of the service, and runs /etc/init.d/<name> start, as a write does for dnsmasq. The stop and the start act on the whole service. Every instance of it stops and starts again, the ones that ran included, such as the other dnsmasq instances, so their clients see a short break. A start sends no SIGHUP, and procd counts the deaths of each new instance from zero. The steps have the bounds of the write: 3 s for the stop, 2 s for the wait and 5 s for the start, taken from reload_budget_s. With a reload_budget_s below 10, uapi skips them and answers 500. A stop still running after 3 s gets no start.

The request takes the global lock shared and the lock of each package whose writes reload the service, as such a write does. It answers 423 locked while such a write runs. Such a write, and a non-uci write such as a package install, answers 423 while the action runs, which takes 10 s at most.

It answers 200 when every instance that procd had given up on runs after the start: recovered names them. It answers 500 recover_failed when one is still down: stopped names each one, service names the service, and message says why, so a client needs no second call. Look at logread for the daemon then. A 200 that carried an Idempotency-Key replays for 24 h.

Management-path warning

The lockout this guards against is the one atomic writes cannot help with: a change that reloads cleanly and then severs the only path to the box. uapi warns rather than refuses, because renumbering the management VLAN or moving to an out-of-band path are legitimate things to do, and because LuCI warns rather than blocking on the same condition.

Two places report it, and they answer different questions.

GET /uapi/diagnostics carries management_path, which names the interface this request arrived through:

{ "management_path": { "address": "192.168.0.236", "device": "eth1", "interface": "wan" } }

That is the pre-flight answer. Ask it before a risky write, or have a wrapper ask it, and you know which interface not to touch. interface is null when the request arrives on a device no uci interface claims, which is honest rather than a guess.

A write to network/interfaces gets X-Mgmt-Path-Warning when it moves that interface's disabled, proto, ipaddrs or netmask, or deletes it. network/devices and network/bridge_vlans are matched by device instead of by interface name, and report device=<name> when a create or a delete names the caller's own device, or a bridge that device is a port of. That is the after-the-fact answer, and it is worth having because most such writes do not actually break the path: the header tells an operator they are in a risky state while the connection still works.

Its limit, stated plainly: if the write really does strand you, the response never arrives. This is not a safety net, it is a warning light. The scope is deliberately LuCI's: those four field names on the inbound interface, and no firewall analysis at all, because predicting a firewall lockout means modelling fw4 zone and rule ordering, and a guess dressed as a warning is worse than silence.

The interface is derived from the kernel's own route lookup rather than by comparing the caller's address against each interface's configured prefixes. An operator reaching the box from another network sits inside no local prefix, and that is exactly the operator a write can strand, so containment arithmetic would report "unknown" for the case that matters most. The route lookup also answers for IPv6, where uapi's own prefix helpers are IPv4-only.

Healthz

curl -k https://<router>/api/v4/healthz
# 200 with body:
# { "status": "ok", "version": "4.0.0",
#   "checks": { "ubus": "ok", "uci": "ok",
#               "lock_dir": "ok", "time_sync": "ok" } }
# 503 with body:
# { "status": "degraded", "version": "...", "checks": {...},
#   "errors": ["ubus: ...", "time_sync: clock not synced (epoch below sanity floor)"] }

No auth required; TLS-for-non-localhost still applies. Monitors should poll healthz (not a real endpoint) to avoid burning audit-log noise. time_sync returns unknown for the first 60 seconds after boot (uptime too short to tell), degraded if the wall clock is below the sanity floor of epoch 1700000000 (14 November 2023), otherwise ok.

version is a stable contract field

The version field returned by /healthz is the canonical version-skew probe. It carries the installed uapi package version (same string as /usr/share/uapi/VERSION) and is guaranteed to be present across every release within and across majors. Clients that need to detect API-skew before issuing real requests should read it from /healthz rather than parsing it from the URL or assuming it from the package they installed.

Insecure-test bypass

For closed-network testing only, creating /etc/uapi.insecure lets plain HTTP through from any client (the loopback bypass is always available; this opens it for remote hosts too). Every request that takes the bypass emits a syslog NOTICE line:

uapi-insecure-bypass <request_id> <method> <path> status=<n> remote=<addr>

so it shows up in logread and any remote-syslog collector. Delete the marker for production use.

Request body deadline

The body of a request has to arrive in full within 10 s of its start (docs/security.md, Public endpoints). Every request that misses the deadline emits a syslog WARNING line, on every path, with no body content:

uapi-body-deadline <request_id> <method> <path> status=<n> remote=<addr>

The status is the answer that the request got: 400 when uapi read the body and it did not arrive in full, or the normal answer of a request that answers without reading its body, such as a 413 or a GET with a declared body. Many such lines from one address are a client that holds the request slots of uhttpd. Without ucode-mod-io there is no deadline, and the handler logs one line when uhttpd starts:

uapi-body-deadline: ucode-mod-io is not installed, so a request body that does not arrive holds its request until the script timeout of uhttpd

Capacity

uapi runs in-process inside uhttpd via uhttpd-mod-ucode. Each request is a forked CGI child. On low-end MIPS hardware, fork+ucode+ubus is in the tens of milliseconds per request; on modern aarch64/x86_64 it is sub-10ms. The intended workload is Terraform applies plus occasional curl, not high-volume RPC. If you need RPS in the hundreds, front uapi with a caching reverse proxy.

Backups

The token store at /etc/config/uapi is the only uapi-specific state worth backing up beyond what you'd back up for OpenWrt itself (sysupgrade --create-backup). Treat it as a secret. The tokens within are hashed (so a leaked backup file doesn't directly expose bearers), but the salts + hashes still allow an offline brute-force on weak inputs; in practice the bearers are 128 random bits so brute force is infeasible, but discipline still wins.