Skip to main content

Extension States

The Extension States endpoint returns the state of every extension in one tenant in a single JSON array, including offline extensions. It supports GET only and has its own advanced-key permission, getExtensionStates.

Endpoint and authentication

GET https://pbx.example.com/pbx/openapi.php/extensions/states?tenant=CANISTRACCI

The equivalent query form is:

GET https://pbx.example.com/pbx/openapi.php?object=extension&action=states&tenant=CANISTRACCI

Full and read-only tenant or global API keys are supported. Send the key with X-API-Key, Authorization: Bearer, or the key query parameter. Extension Dial API keys are not supported.

An Advanced Open API Key must explicitly authorize GET /extensions/states (getExtensionStates) and the selected tenant. Global administrative permission is not required. Permission to list extensions or read one extension's live state does not grant this aggregate operation. Adding this endpoint does not automatically expand existing keys.

Parameters

ParameterRequiredDescription
tenantYesOne exact tenant code or name. Codes take precedence over names. Ambiguous names and wildcard tenant selection are rejected, including for global keys.
liveNoDefaults to true. Use false for cached device states only. 1 and 0 are accepted aliases.
keyUnless an authentication header is usedAn API key authorized for this operation and tenant.

Omit id, objectid, number, and ext: this endpoint always covers all extensions. It does not use a reserved value such as number=ALL.

Examples

curl -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/extensions/states?tenant=CANISTRACCI"

curl -H "Authorization: Bearer TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/extensions/states?tenant=CANISTRACCI&live=false"

curl -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php?object=extension&action=states&tenant=CANISTRACCI"

Response

The response is always an array, ordered by extension number and internal ID. An empty tenant returns []. Missing backend mappings do not remove extensions from the result.

[
  {
    "id": 134,
    "number": "103",
    "name": "Reception",
    "tech": "PJSIP",
    "state": "RINGING",
    "dnd": false,
    "device_state": "NOT_INUSE",
    "active_channels": 1,
    "live_status": "ok"
  },
  {
    "id": 135,
    "number": "104",
    "name": "Warehouse",
    "tech": "SIP",
    "state": "UNAVAILABLE",
    "dnd": false,
    "device_state": "UNAVAILABLE",
    "active_channels": 0,
    "live_status": "ok"
  }
]
FieldTypeMeaning
idIntegerExtension internal ID.
numberStringDialable extension number; leading zeros are preserved.
nameStringExtension display name.
techStringConfigured technology, such as SIP, PJSIP, CUSTOM, or VIRTUAL.
stateStringCached device state, overlaid with observed live channel activity. Observed channels can produce INUSE, RINGING, or RINGINUSE. Cached ONHOLD and BUSY states are preserved for observed non-ringing calls. Without observed channels, the cached state is retained.
dndBooleanConfigured extension Do Not Disturb flag, independent of channel activity.
device_stateString or nullNormalized cached state before the live overlay; null when no trustworthy peer mapping or sample exists.
active_channelsInteger or nullObserved channel count for a complete live snapshot. Null when live collection is disabled, unsupported, or incomplete. This counts channels, not distinct conversations.
live_statusStringok: complete live snapshot; partial: at least one node failed to provide a valid snapshot; cached_only: live collection disabled or channel attribution unsupported.

Recognized cached states are UNKNOWN, NOT_INUSE, INUSE, BUSY, INVALID, UNAVAILABLE, RINGING, RINGINUSE, and ONHOLD. Missing or ambiguous peer mappings return state: "UNKNOWN" and device_state: null.

An idle phone with DND enabled may return state: "INUSE", dnd: true, and active_channels: 0. Zero observed channels does not reset a cached device state to NOT_INUSE.

Live collection and cached mode

By default, device states are read in batches and live collection uses one connection and one fixed core show channels concise command per configured PBX node. There are no separate commands for each extension or channel. Each connection/socket read has a two-second timeout; new nodes stop being admitted after a 20-second collection budget.

SIP/PJSIP channels are matched by exact device name and exact tenant account code. Virtual extensions also observe their own tenant's physical members; custom extensions use cached state only. Ambiguous ownership across technologies, tenants, or canonical device-state aliases is excluded. Identically named channels on different nodes are counted separately.

If a node fails, live-capable entries report live_status: "partial" and active_channels: null, while retaining the cached state and any observed overlay. A successful empty live snapshot returns zero channels, which differs from an unavailable snapshot.

With live=false, the endpoint reads cached states only, does not read AMI credentials, and makes no AMI connection. Channel counts are null and live_status is cached_only. Neither mode returns credentials, registration addresses, channel names, caller IDs, or other tenants' call details.

Node snapshots are sequential rather than one atomic cluster-wide instant. The device-state cache has no sample timestamp and may be stale if its sender/receiver is stopped.

Errors

HTTP statusReason
400Missing or invalid exact tenant selection, unsupported identifier filters, another action combined with the endpoint, or an invalid live value.
401Missing, unknown, revoked, or expired API key.
403Disallowed IP, tenant, or endpoint; or OpenAPI disabled for the tenant. A missing advanced-key operation returns api_endpoint_not_allowed.
404Tenant or requested route not found.
405A method other than GET was used.
409The tenant display name is ambiguous; use its unique code.
503Database lookup failed (extension_states_unavailable) or the key policy could not be verified.
  • GET /extensions lists basic extension information without this state snapshot.
  • GET /extensions/state?tenant=...&number=... returns live call details for one extension and retains its existing object response.
  • Extension detail endpoints retain their existing cached state and configuration fields.