Skip to content

cloudSwXtch API

View as Markdown

Overview

The cloudSwXtch API is intended for use to integrate the cloudSwXtch data with third-party tools for monitoring and dashboard purposes within customer user interfaces. This section will outline the API, with examples of data results. Timestamps in the API are Epoch Unix Timestamps.

The API is available in wXcked Eye by selecting the API button.

wXcked Eye top bar with the API button highlighted

After selection, the interface shows the API Documentation page. Calls are separated by category, and each call can be expanded for information on the specific call.

API Docs page with callouts: the category buttons (System, swXtch and swXtchBridge) and the expand arrow on a call for its details

Calls are documented by category below:

API Categories

There are two main categories in the API, and each category has its own sub-categories:

Clients and capture

These OMNI endpoints (https://{OMNI-ctrl-ip}:8443, session token) automate what Authorizations does in wXcked Eye:

  • POST /swx/clients/authorizationState (Reader): list the clients, pending ones included ({"authorized": false} lists only those).
  • POST /swx/clients/authorize (Admin): approve pending xNICs and swXtchBridges, {"items":[{"address":"<ip>","componentKindCode":"xnic"}]} (bridge for a swXtchBridge); /swx/clients/unauthorize withdraws an approval.
  • POST /swx/clients/createEnrollToken (Admin): create an enrol token, {"displayName":"<name>"}.
  • POST /swx/swxtches/manageSwxtch (Admin): capture a cloudSwXtch.

Where each API is served

API Base URL Authentication
Authentication (/swx/auth/*) https://{OMNI-ctrl-ip}:8443 API key or refresh token in the request body (see Security)
System (monitoring, clusters, HA, flows) https://{OMNI-ctrl-ip}:8443 Session token in the Swxtch-Auth-Token header
swXtch services (/swx/services, /swx/services/version, /swx/services/checksum, /swx/services/install/*) https://{cloudSwXtch-ctrl-ip}:9443 None
swXtch adaptors (/swx/adaptors/*) https://{cloudSwXtch-ctrl-ip}:9443 Session token from OMNI in the Swxtch-Auth-Token header
swXtch statistics (/swx/stats/*) https://{cloudSwXtch-ctrl-ip}:9443 Session token from OMNI in the Swxtch-Auth-Token header (Reader)
swXtch Prometheus metrics (/swx/prometheus/metrics) https://{cloudSwXtch-ctrl-ip}:9443 OMNI API key as a bearer token (Authorization: Bearer <API-key>), or a session token; Reader. See Prometheus Monitoring
API documentation (/swx/doc/*, /api/wxckedeye/doc/*) and the topology index (/api/topology/index) https://{OMNI-ctrl-ip}:8443 Session token in the Swxtch-Auth-Token header (Reader)

The swXtch endpoints answer only on the cloudSwXtch (port 9443), not through OMNI on port 8443. The certificates are issued by OMNI's own CA (a cloudSwXtch that no OMNI captured yet serves a self-signed one), which curl does not know: trust OMNI's CA with --cacert, or pin the server's key with -k --pinnedpubkey sha256//<pin> (swx-cli swxtch pin on a cloudSwXtch host, swx-cli cert pin on the OMNI host). -k alone checks nothing.

Changes from v4

The v4 Monitoring and Configuration APIs (/services/settings, /swxtch/ha/v1/*, /swxtch/protocols/v1/*, /swxtch/monitoring/v1/*, /api/topology/v1/topology) do not exist in v5. Use the System API instead. The swXtchBridge API is not documented for v5: configure the swXtchBridge from wXcked Eye and swx-cli.

The API documentation in wXcked Eye (API button) shows the System API and the swXtch API (adaptors and services).

Content type: application/json (unless specified otherwise)

Context: /swx/

Security

All API calls require an authenticated session. Note: an API key is exchange-only; it is never sent directly on API calls. The one exception is the Prometheus metrics of a cloudSwXtch, which also take the API key itself as a bearer token, because a Prometheus scraper cannot open a session first.

The read-only pages need a session too, and the Reader role is enough: the swXtch statistics (/swx/stats/*), the schema comparison pages of every endpoint (.../diff/argument and .../diff/result), the API documentation (/swx/doc/* and /api/wxckedeye/doc/*) and the topology index (/api/topology/index). Without a session they answer 401.

These remain public, without a session: the installer downloads and their help (/swx/services, /swx/services/install/*, including the trust bundle /swx/services/install/ca-bundle.pem), /swx/services/checksum, /swx/services/version, the cloudSwXtch /help page, and the endpoints that open a session (/swx/auth/createSessionWithKey, createRefreshToken, createSessionWithToken and renewRefreshToken, see below), which take the credential in the request body.

To get a session, exchange your API key for a short-lived session token: POST /swx/auth/createSessionWithKey with your API key in the request body. The response includes a Swxtch-Auth-Token, which you then pass as a header on every subsequent API call. Session tokens are valid for 5 minutes of inactivity (60 minutes absolute). A session opened with an API key that has an expiration date also ends when the key expires, and ends when the key is deleted.

Example:

curl -s -k --pinnedpubkey sha256//{OMNI-pin} -X POST -H "Content-Type: application/json" \
  -d '{"apiKey":"swxk_Qm3vT8yLp2Kc9wXr.aXeK9F2pQmZ8vB3nR7tY1cW6hL0sD4gJ5uN2oI8eA3rM"}' \
  https://{OMNI-ctrl-ip}:8443/swx/auth/createSessionWithKey

Verify OMNI before sending a key

OMNI's certificate is issued by OMNI's own CA (or is a certificate of your own, see Certificates), which curl does not know. Do not send an API key or a session token with -k alone: pin OMNI's key with --pinnedpubkey (swx-cli cert pin on the OMNI host prints it; -k then only skips the name and CA checks), or trust OMNI's CA with --cacert. OMNI serves its trust bundle at /swx/auth/trustBundle. The other examples in this API reference use curl -sk for brevity. See How identity and trust work.

Example response:

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.mock.signature",
  "username": "jdoe",
  "roleCode": "admin",
  "idledeadline": "2026-07-31T14:47:41Z",
  "expiry": "2026-07-31T15:42:41Z"
}

To extend session time, use a refresh token instead of repeating your API key: POST /swx/auth/createRefreshToken with your API key returns a refresh token (in the token field) valid up to 24 hours. Use POST /swx/auth/createSessionWithToken with the body {"refreshToken":"<refresh token>"} to mint new session tokens as needed, without re-sending your API key. Call POST /swx/auth/renewRefreshToken, with the same body, before the 24-hour window expires to extend it further.

Failed password logins never lock a user out. A wrong password answers Invalid credentials.

The HTTPS servers of OMNI and the cloudSwXtch close a connection that does not complete the TLS handshake and send its request headers within 10 seconds, and an idle keep-alive connection after 120 seconds. A request body (or its parameters) is limited to 8 MiB. Browsers refuse cross-origin calls to the API unless OMNI's acceptedDomains lists the calling origin exactly (scheme://host[:port]); wXcked Eye itself is served from the same origin and is not affected.

Errors are returned as JSON with an errorCode, an errorMessage and a correlationId to quote to support.

Example:

curl -s -k --pinnedpubkey sha256//{OMNI-pin} -X POST -H "Content-Type: application/json" \
  -d '{"apiKey":"swxk_Qm3vT8yLp2Kc9wXr.aXeK9F2pQmZ8vB3nR7tY1cW6hL0sD4gJ5uN2oI8eA3rM"}' \
  https://{OMNI-ctrl-ip}:8443/swx/auth/createRefreshToken

Example response:

{
  "token": "rXfR3sHm0cKtOkEn8vQpL2wY5dNzB7aGjU4iVh9sTq",
  "username": "jdoe",
  "roleCode": "admin",
  "expiry": "2026-08-01T14:47:41Z"
}

An API key has the form swxk_<key id>.<secret>: the key id names the stored key, and OMNI checks the secret only against that one. Always use the whole value as shown when the key was created.

At install, OMNI writes an admin API key to /var/opt/swx/omni/install-keys/admin-api-key on the OMNI host (readable by root only).

For instructions on obtaining an API key, see How to Obtain an API Key.