# PBX Nodes

The **PBX Nodes** resource returns the operational information shown in **Admin → PBX Nodes** (`nodes.php`): saved system health and service checks, plus optional live Asterisk readings. It is read-only.

## Endpoints and authentication

```
GET https://pbx.example.com/pbx/openapi.php/nodes
GET https://pbx.example.com/pbx/openapi.php/nodes/{id}
```

Use a **full or read-only global API key**. Send it with `X-API-Key`, `Authorization: Bearer`, or the `key` query parameter. Normal API IP restrictions apply. Tenant keys and extension Dial API Keys cannot read this resource. **Omit `tenant`**, including when using a global key. Only GET is supported; these endpoints cannot change node configuration.

## Parameters and pagination

<table id="bkmrk-parametermeaningidnu"><thead><tr><th>Parameter</th><th>Meaning</th></tr></thead><tbody><tr><td>`id`</td><td>Numeric node ID. Supply it in `/nodes/{id}` or as a query parameter. Both forms return one object in `data`; conflicting IDs are rejected.</td></tr><tr><td>`live`</td><td>`true` by default. Include live Asterisk version, peer/contact counts, channels/calls and ODBC state. Use `false` for database readings without an AMI connection.</td></tr><tr><td>`limit`</td><td>For lists: 1–100 nodes per page; default 10.</td></tr><tr><td>`offset`</td><td>For lists: number of nodes to skip, default 0; maximum 10,000,000. A nonzero offset is not accepted for a single-node request.</td></tr></tbody></table>

`GET /nodes` returns an array in `data`, ordered by numeric node ID. Read `has_more` and use `next_offset` to retrieve the next page. A missing single node returns 404; an empty list page returns `data: []`.

## Examples

```
# All returned nodes, including live AMI readings
curl -H "X-API-Key: GLOBAL_READONLY_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/nodes"

# One node, saved/database readings only
curl -H "X-API-Key: GLOBAL_READONLY_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/nodes/3?live=false"

# A bounded page for monitoring without AMI
curl -H "X-API-Key: GLOBAL_READONLY_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/nodes?live=false&limit=10&offset=0"

# Equivalent query-style single-node request
curl -H "X-API-Key: GLOBAL_READONLY_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php?object=nodes&action=get&id=3&live=false"
```

The query-style list form is `openapi.php?object=nodes&action=list&live=false`. The OpenAPI specification lists these operations as `listNodes` and `getNode` in its global catalog.

## Response fields

<table id="bkmrk-fieldmeaningobjectno"><thead><tr><th>Field</th><th>Meaning</th></tr></thead><tbody><tr><td>`object`</td><td>`nodes` for both list and single-node responses.</td></tr><tr><td>`generated_at`, `timezone`</td><td>Response snapshot time and PBX server timezone. This is not a new collection timestamp for saved metrics.</td></tr><tr><td>`data`</td><td>Node objects for a list, or one node object for an ID lookup.</td></tr><tr><td>`limit`, `offset`, `has_more`, `next_offset`</td><td>Pagination. `next_offset` is null on the last page.</td></tr><tr><td>`peers_online_on_page`</td><td>Sum of the live peer/contact counts for the returned nodes only; null when a returned count is unavailable or live readings are disabled. It is not a cluster total when pagination is used.</td></tr><tr><td>`context`</td><td>AI processing backlogs for returned processing nodes, cluster housekeeping and the database auto-increment capacity check.</td></tr></tbody></table>

<table id="bkmrk-node-fieldmeaningid%2C"><thead><tr><th>Node field</th><th>Meaning</th></tr></thead><tbody><tr><td>`id`, `name`, `peer_name`, `ip_address`, `pbx_version`</td><td>Node identity, host address and installed PBX version.</td></tr><tr><td>`os`</td><td>`version`, pending `security`/`normal` updates, last `checked` timestamp, upgrade `status`, `error` text and `health` colour. End-of-life status or pending security updates is red; other pending updates yellow.</td></tr><tr><td>`checks.croncheck`</td><td>Saved scheduling cursor and freshness check. Includes wall-clock `last_check`, effective `epoch`, `stored_epoch`, `age_seconds`, `threshold_seconds`, `future` and `status`.</td></tr><tr><td>`checks.devstate`</td><td>Saved device-state heartbeat with a 1,800-second threshold; installed and expected versions, ping and pong timestamps.</td></tr><tr><td>`checks.geoip_module`, `checks.geoip_data`, `checks.dahdi`</td><td>Saved GeoIP module/data and DAHDI status values and colours.</td></tr><tr><td>`checks.asterisk_recovery`</td><td>Whether automatic recovery is enabled, saved recovery state, last restart timestamp and status.</td></tr><tr><td>`services.amirouter`, `services.openaigateway`</td><td>Configured enable value, saved runtime state, installed/expected versions, icon state and status.</td></tr><tr><td>`services.voipmonitor`</td><td>Whether VoIPmonitor is enabled and its saved status message.</td></tr><tr><td>`system`</td><td>CPU cores and governor, system/Asterisk uptime in seconds, three load averages, memory, swap, disks, recordings awaiting processing and firewall suspension minutes. `cached` is true because these measurements come from stored samples.</td></tr><tr><td>`live`</td><td>AMI availability, probe time, live Asterisk readings, four ODBC link states and warning codes.</td></tr></tbody></table>

Memory fields are `total_bytes`, `used_bytes`, `free_bytes`, `shared_bytes`, `buffers_bytes`, `cached_bytes`, `page_free_ratio` and `status`. They follow the stored `free` command positions displayed by the web page; the meaning of its last columns can differ across OS versions. `page_free_ratio` follows the page calculation, `(free + cached) / total`. Swap returns total, used and free bytes, free ratio and status.

Each `system.disks` entry contains `filesystem`, `mount`, total/used/available bytes, `used_percent` and status. Usage is yellow above 80% and red above 90%, including 100%. Health colours are `green`, `yellow`, `red` or `unknown`. Missing or malformed samples yield null/unknown values rather than fabricated healthy zero readings. The existing page memory, swap and recordings alert semantics are retained.

## Reading the croncheck cursor

`checks.croncheck.last_check` corresponds to `no_nodes.no_croncheck`. `stored_epoch` is `no_nodes.no_croncheck_epoch`, when available; the effective `epoch` falls back to the legacy timestamp when no valid stored epoch exists. The freshness threshold is **360 seconds**. The `future` flag helps identify a saved cursor ahead of the current time.

This cursor records the last completed scheduling minute, not the exact finish time of every croncheck task. It can lag during backlog processing. During daylight-saving clock changes, use the epoch rather than comparing ambiguous wall-clock strings. This endpoint reads the cursor; it never advances or resets it.

Example excerpt from a single-node response; other response fields are omitted:

```
{
  "object": "nodes",
  "generated_at": "2026-12-01T11:02:00+00:00",
  "timezone": "Europe/Rome",
  "data": {
    "id": 3,
    "checks": {
      "croncheck": {
        "last_check": "2026-12-01 12:00:00",
        "epoch": 1796122800,
        "age_seconds": 120,
        "threshold_seconds": 360,
        "future": false,
        "status": "green",
        "stored_epoch": 1796122800
      }
    }
  }
}
```

## AI queues, housekeeping and database capacity

`context.ai_queues` contains entries with `type` (`transcript`, `summary` or `sentiment`), `node_id`, `pending` and `status`. Only processing nodes returned on this page are included. As in the web page, the count includes entries first checked in the last day or not yet checked. It is green below 100, yellow below 1,000, otherwise red.

`context.housekeeping` identifies the cluster node with the latest housekeeping start, together with start/end timestamps and completion status. `context.database_capacity` returns the page’s database-wide auto-increment capacity check: database/table/column, column type, next ID, maximum ID, percentage and status. Large IDs are strings to preserve their precision. These two checks are cluster-wide, including for a single-node request.

## Saved data and live AMI readings

`live=true` opens one AMI connection per returned, configured node, with events disabled, and issues only fixed read commands: `sip show peers`, `pjsip list contacts`, `core show version`, `core show channels count`, and `odbc show` for `asterisk1`, `asterisk2`, `asteriskcdrdb1` and `asteriskcdrdb2`.

<table id="bkmrk-live-fieldmeaningreq"><thead><tr><th>Live field</th><th>Meaning</th></tr></thead><tbody><tr><td>`requested`, `available`, `partial`</td><td>Whether live data was requested, an AMI connection succeeded, and some requested readings were unavailable.</td></tr><tr><td>`checked_at`</td><td>Time of a probe attempt, not proof of a successful connection. Null when live probing was disabled or not admitted due to the request budget.</td></tr><tr><td>`asterisk_version`</td><td>Live Asterisk version.</td></tr><tr><td>`sip_peers_online`</td><td>Monitored SIP peers reported online by Asterisk.</td></tr><tr><td>`pjsip_contacts`</td><td>PJSIP contact objects, including multiple contacts for one endpoint. This is not a distinct endpoint or phone count.</td></tr><tr><td>`peers_online`</td><td>SIP plus PJSIP counts, or null if either is unavailable.</td></tr><tr><td>`active_channels`, `active_calls`, `calls_processed`</td><td>Live Asterisk channel/call counters.</td></tr><tr><td>`odbc`</td><td>For each queried link: name, connected state, active and maximum connection counts, and status.</td></tr><tr><td>`warnings`</td><td>Machine-readable reasons for unavailable or partial live data.</td></tr></tbody></table>

A missing SIP/PJSIP channel driver contributes zero for that technology. An empty, failed or unrecognized response contributes null. Nodes are queried sequentially, so the response is not an atomic cluster snapshot. A healthy cached reading is not proof of a successful live connection.

AMI failure does not discard the saved node data. The response is HTTP 200 with explicit unavailable/partial live fields and warnings. Warning codes include `ami_not_configured`, `ami_client_unavailable`, `ami_connection_failed`, `ami_request_failed`, `ami_response_unavailable_*`, `ami_time_budget_exceeded` and `ami_request_budget_exceeded`.

Connection and socket reads use a two-second timeout. There is a per-node command budget and a 20-second budget for admitting more node probes. These are best-effort limits, not a hard HTTP deadline; an in-progress probe can finish later. Paginate larger clusters or use `live=false` for monitoring that must avoid AMI.

`live=false` does not instantiate an AMI client or select AMI credentials. Saved health/service values can be stale. Queue counts and global context are still read from the database. `generated_at` is the response snapshot time, not the collection time of every stored value; no extra freshness timestamp is invented.

## Errors and access boundaries

<table id="bkmrk-http-status-%2F-codeme"><thead><tr><th>HTTP status / code</th><th>Meaning</th></tr></thead><tbody><tr><td>`400 invalid_nodes_request`</td><td>Invalid ID, pagination, live flag or conflicting selectors.</td></tr><tr><td>`400 tenant_not_applicable`</td><td>Tenant supplied for a global operation; omit it.</td></tr><tr><td>`401 missing_api_key` / `invalid_api_key`</td><td>Missing or invalid credentials.</td></tr><tr><td>`403 admin_required` / `api_ip_not_allowed`</td><td>A verified tenant key is not a global key, or the normal API IP filter denied access.</td></tr><tr><td>`404 node_not_found` / `not_found`</td><td>Requested node or route does not exist.</td></tr><tr><td>`405 method_not_allowed`</td><td>Only GET is supported; standard OpenAPI OPTIONS handling is available.</td></tr><tr><td>`503 node_status_unavailable`</td><td>The server could not read the node status from the database. Internal SQL and credentials are not returned.</td></tr></tbody></table>

The response uses an explicit allowlist. It does not expose AMI usernames/passwords, health-probe passwords or arbitrary configuration columns. Repository URL credentials and common secret query parameters are redacted from error text. Standard OpenAPI authentication, auditing and usage accounting apply. No node updates, cron cursor changes, job submissions, module reloads or service restarts are performed.