Admin REST API

Inspect and manage a running broker over HTTP — status, sessions, subscriptions, retained messages and the authentication and authorization chains — with curl examples.

The admin API is a small JSON-over-HTTP API for one node, served on its own listener, separate from every MQTT listener. It also serves the Prometheus /metrics endpoint. Every endpoint, schema and error is listed in the generated Admin API reference.

Enabling it

orbitmq.toml
[admin]
enabled = true                       # the default
listen = "127.0.0.1:18083"           # the default
tokens = ["a-long-random-token"]     # one or more accepted bearer tokens
request_timeout_ms = 2000            # the default

The API starts only when enabled = true and at least one token is configured. Without tokens it stays off (the broker logs admin API disabled). For local experiments you can instead set insecure = true, which serves the API without authentication; this is refused unless listen is a loopback address and no tokens are set.

The same settings are available as environment variables:

ORBITMQ_ADMIN_TOKENS='token-one,token-two' ORBITMQ_ADMIN_LISTEN=0.0.0.0:18083 ./target/release/orbitmq

Generate tokens with a random source, for example openssl rand -hex 32. Without tls the admin listener speaks plain HTTP, so bearer tokens travel in clear text; when listen is not a loopback address and tls is unset, the broker logs a warning at start-up. Either set tls, or bind to loopback behind a TLS-terminating proxy. If a host name is used to reach the API, list it in allowed_hosts.

TLS

orbitmq.toml
[admin]
listen = "0.0.0.0:18083"
tokens = ["a-long-random-token"]
tls = { cert = "/etc/orbitmq/admin.pem", key = "/etc/orbitmq/admin.key" }
allowed_hosts = ["broker1.example.internal"]

tls takes the keys of [listener.tls] (cert, key, and optionally client_ca and require_client_cert to ask for client certificates). ALPN defaults to http/1.1. The API, /metrics and the dashboard are then served over HTTPS only. A TLS handshake must finish within 10 seconds, and at most 64 run at once.

Authentication

Every request needs an Authorization header with one of the tokens:

export ORBITMQ_TOKEN=a-long-random-token
curl -H "Authorization: Bearer $ORBITMQ_TOKEN" http://127.0.0.1:18083/api/v1/status

A missing or wrong token gets 401 with WWW-Authenticate: Bearer realm="orbitmq". Tokens are compared in constant time.

  • Failed tokens. Each wrong token is logged with the peer address. After 10 wrong tokens in a row from one address, that address gets 429 too_many_failures with a Retry-After header for 1 second, a period that doubles with every further failure up to 5 minutes. A valid token resets the count, and an address with no failure for 15 minutes is forgotten.
  • Audit log. Every state-changing request (POST, PUT, PATCH, DELETE) is logged under the target orbitmq::admin::audit with its method, path, status, peer and a fingerprint of the token that authorised it (the first 8 bytes of its SHA-256, never the token itself).

Request guards

These checks run before authentication:

  • Host check (DNS rebinding). The Host header must name an IP address, localhost (or a name ending in .localhost), or a host listed in allowed_hosts (env ORBITMQ_ADMIN_ALLOWED_HOSTS, comma-separated). Other requests get 421 host_not_allowed. allowed_hosts = ["*"] accepts any host. This applies to every path on the admin listener, the dashboard and /metrics included.
  • Cross-site requests in insecure mode. With insecure = true no token protects the API, so a state-changing request (POST, PUT, PATCH, DELETE) must carry something a cross-site page cannot send without a CORS preflight (which the API never answers): Content-Type: application/json, an X-OrbitMQ-Request header (any value) or Sec-Fetch-Site: same-origin. Otherwise it gets 403 csrf. With tokens, every request carries Authorization, which already rules this out.
  • Event streams. At most max_streams (default 32, env ORBITMQ_ADMIN_MAX_STREAMS) server-sent event streams (/api/v1/logs, /api/v1/metrics/stream) are open at once; further ones get 429 too_many_streams.
# insecure = true on loopback: a state-changing request needs one of the headers above
curl -X DELETE -H 'X-OrbitMQ-Request: 1' http://127.0.0.1:18083/api/v1/clients/sensor-1

Errors

Errors are JSON with a stable error code and a human-readable message:

{ "error": "not_found", "message": "no session for client \"sensor-1\"" }
StatuserrorMeaning
401unauthorizedMissing or invalid bearer token.
403csrfInsecure mode: a state-changing request without a JSON body, X-OrbitMQ-Request or Sec-Fetch-Site: same-origin.
421host_not_allowedThe Host header names neither an IP address, localhost nor one of allowed_hosts.
429too_many_failuresToo many invalid tokens from this address; see Retry-After.
429too_many_streamsmax_streams event streams are already open.
400invalidAuth chains: an invalid order or source configuration; nothing changed.
400invalid_ruleRules: an invalid rule or request; field, and for SQL line and column, say where.
404not_foundNo such session, chain, source or rule, or no such endpoint.
404not_connectedKick: the client is not connected.
409connectedSession delete: the client is connected; kick it first.
409conflictAuth chains: the chains changed since the revision you sent; reload and retry. Rules: a rule with this id exists.
409read_onlyRules: the rule is defined in orbitmq.toml; change it there.
500persist_failedAuth chains or rules: the state file could not be written; nothing changed.
503busyA core's control queue is full; retry later.
503stoppingThe broker is shutting down.
503unavailableRules: the rule engine is disabled ([rules] enabled = false).
504timeoutNot every core answered within request_timeout_ms.

How queries work

Sessions, subscriptions and retained messages live on the data-plane cores, not in a shared table. Each query is sent to every core over its control ring; the cores answer between other events, and the admin thread merges the answers. The publish path never waits for the admin API.

Node status

curl -s -H "Authorization: Bearer $ORBITMQ_TOKEN" http://127.0.0.1:18083/api/v1/status
{
  "version": "0.0.0",
  "uptime_seconds": 1,
  "started_at": 1791915692,
  "cores": 2,
  "listeners": [{ "name": "default", "kind": "tcp", "address": "127.0.0.1:1883" }],
  "io_backend": "epoll",
  "io_uring_unavailable": "io_uring_setup returned EPERM: blocked by seccomp (container default profile)"
}

io_backend is the I/O backend the data-plane cores run on: io_uring or epoll on Linux, kqueue on macOS. io_uring_unavailable explains, on Linux, why io_uring is not in use (a seccomp filter, the kernel.io_uring_disabled sysctl or an old kernel); it is null when io_uring is in use and on other platforms. See Running in containers.

Sessions

GET /api/v1/clients lists connected and stored sessions, sorted by client identifier, one page at a time.

Query parameterMeaning
limitPage size, 1 to 1000 (default 100).
cursorThe next_cursor of the previous page.
client_id_prefixOnly client identifiers starting with this prefix.
curl -s -H "Authorization: Bearer $ORBITMQ_TOKEN" \
  'http://127.0.0.1:18083/api/v1/clients?limit=100&client_id_prefix=sensor-'
{
  "data": [
    {
      "client_id": "sensor-1",
      "connected": true,
      "core": 0,
      "protocol": "5.0",
      "listener": "default",
      "peer": "127.0.0.1:53663",
      "username": null,
      "session_expiry_interval": 3600,
      "expires_in": null,
      "subscription_count": 1,
      "inflight": 0,
      "queued": 0,
      "dropped": 0
    }
  ],
  "next_cursor": null
}

While next_cursor is not null, pass it as cursor to fetch the next page.

GET /api/v1/clients/{id} returns one session with its subscriptions. Percent-encode the client identifier in the path, for example a%2Fb for the client a/b:

curl -s -H "Authorization: Bearer $ORBITMQ_TOKEN" http://127.0.0.1:18083/api/v1/clients/sensor-1

For a disconnected session, connected is false, protocol and listener are null, and expires_in counts down the seconds until the session expires.

Disconnecting a client

curl -s -X DELETE -H "Authorization: Bearer $ORBITMQ_TOKEN" http://127.0.0.1:18083/api/v1/clients/sensor-1
  • 204: the connection was closed. MQTT 5.0 clients first receive DISCONNECT with reason code 0x98 (Administrative action).
  • The Will Message is published, as for any disconnect the server initiates.
  • The session then follows its expiry rules: a session with a non-zero Session Expiry Interval is kept.

Deleting a stored session

curl -s -X DELETE -H "Authorization: Bearer $ORBITMQ_TOKEN" http://127.0.0.1:18083/api/v1/sessions/sensor-1

Removes the stored session of a client that is not connected: its subscriptions and its queued and in-flight messages. A pending Will Message is published, as when a session ends. If the client is connected, the response is 409 connected; disconnect it first with the request above.

Subscriptions

curl -s -H "Authorization: Bearer $ORBITMQ_TOKEN" \
  'http://127.0.0.1:18083/api/v1/subscriptions?topic_filter_prefix=devices/&limit=500'
{
  "data": [
    {
      "client_id": "sensor-1",
      "topic_filter": "devices/+/telemetry",
      "qos": 1,
      "no_local": false,
      "retain_as_published": false,
      "retain_handling": 0
    }
  ],
  "truncated": false
}

Results are sorted by topic filter, then client identifier. topic_filter_prefix matches the filter as subscribed, including any $share/{group}/ prefix; shared subscriptions also carry share_group, and MQTT 5.0 subscriptions with an identifier carry subscription_identifier. truncated is true when more entries matched than limit (1 to 1000, default 100).

Retained messages

curl -s -H "Authorization: Bearer $ORBITMQ_TOKEN" \
  'http://127.0.0.1:18083/api/v1/retained?topic_prefix=devices/'
{ "data": [{ "topic": "devices/sensor-1/status", "qos": 1, "payload_size": 6 }], "truncated": false }

Only metadata is returned, never payloads: topic, QoS, payload size, and, when set, expires_in (seconds) and content_type.

Authentication and authorization chains

/api/v1/auth/authentication and /api/v1/auth/authorization list the two chains in priority order and change them at runtime: reorder (PUT …/order), enable or disable (PATCH …/sources/{name}), add (POST …/sources), replace (PUT …/sources/{name}) and remove (DELETE …/sources/{name}) sources.

curl -s -H "Authorization: Bearer $ORBITMQ_TOKEN" http://127.0.0.1:18083/api/v1/auth/authentication
{
  "chain": "authentication",
  "revision": 3,
  "persisted": true,
  "state_file": "/etc/orbitmq/orbitmq.auth-state.toml",
  "from_state_file": false,
  "allow_anonymous": false,
  "sources": [
    {
      "name": "local",
      "kind": "password_file",
      "enabled": true,
      "position": 0,
      "status": "active",
      "config": {
        "kind": "password_file", "name": "local", "enabled": true, "timeout_ms": 3000, "on_error": "deny",
        "on_not_found": "ignore", "max_in_flight": 256,
        "cache": { "ttl_secs": 60, "negative_ttl_secs": 5, "max_entries": 10000 },
        "path": "/etc/orbitmq/passwords"
      },
      "metrics": { "allow": 120, "deny": 2, "ignore": 41, "checks": null, "errors": null, "cache_hits": null, "last_error_at": null }
    }
  ]
}

config shows every key with its effective value, secrets redacted. Send revision back with a change to get 409 conflict instead of overwriting someone else's change. Changes are kept in the auth state file. The semantics, every endpoint and examples are in Changing the chains at runtime.

Rules and connectors

/api/v1/rules lists, creates, replaces and deletes SQL rules at runtime; POST /api/v1/rules/test evaluates SQL against a sample message without storing anything; GET /api/v1/rules/{id}/metrics returns the counters of a rule and its actions; GET /api/v1/connectors lists the MQTT and Kafka connectors with their status. Rules from orbitmq.toml are read-only here; rules created through the API are kept in the rules state file.

curl -s -X POST -H "Authorization: Bearer $ORBITMQ_TOKEN" -H 'Content-Type: application/json' \
  http://127.0.0.1:18083/api/v1/rules/test \
  -d '{"sql": "SELECT payload.temp AS t FROM \"sensors/#\" WHERE t > 30", "context": {"topic": "sensors/a", "payload": "{\"temp\": 31}"}}'
{ "matched": true, "passed": true, "output": { "t": 31 } }

Every endpoint, with examples, is in Rules and integrations.

Dashboard

With dashboard = true (the default, env ORBITMQ_ADMIN_DASHBOARD), the admin listener also serves the built-in dashboard at /dashboard/; / redirects there. The page files are public; the API calls they make need a token like any other request. Its Auth & ACL page shows both chains and reorders, enables and disables their sources. Its Rules page lists, tests, creates and edits rules and shows the connectors (see Dashboard).

Licence notices

GET /licenses.txt returns, as plain text, the licence texts and notices of the third-party software compiled into the binary: the Rust crates and the embedded dashboard's packages. It needs no token, like the dashboard's files, and is served whether or not the dashboard is enabled. orbitmq --licenses prints the same text and exits.

curl -s http://127.0.0.1:18083/licenses.txt | head
orbitmq --licenses > THIRD_PARTY_NOTICES.txt

On this page