Skip to content

API Reference ​

The REST API primarily uses /api/v1 and returns successful responses in this form:

json
{
  "success": true,
  "data": {}
}

Error responses use this form:

json
{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Readable message",
    "detail": {}
  }
}

API Layers ​

WFM exposes four HTTP API layers rather than a single browser API:

LayerPrefixCallerNotes
Console API/api/v1Browser console and trusted external callersMain business API. Requires an administrator Bearer token by default.
Client API/api/client/v1wfmctl bind/updateBinding uses a one-time token; updates use existing node credentials, not administrator session tokens.
Internal API/api/internalEMQX and other internal componentsIntended for containers or trusted networks and requires an internal shared key.
Dev API/api/v0Local development and automated testsRegistered only when WFM_ENABLE_DEV_TEST_API=true.

The MCP HTTP endpoint is /mcp. MCP tools must reuse the same service logic behind the console API rather than bypassing the business layer.

Calling Conventions ​

Administrator Session ​

Console business APIs normally use:

http
Authorization: Bearer <admin-session-token>

Login, setup, health checks, and a small number of other endpoints allow anonymous access. Download endpoints may also accept download-specific tokens.

Source Restrictions ​

In production, the backend validates the configured public origin and the proxied Host. Browser requests must come from an allowed origin; CLI and curl requests without an Origin are accepted only for the primary Host. Development mode may relax these checks.

Download Tokens ​

Client artifacts, bulk config packages, and snapshot exports can use five-minute single-file download tokens. A token can access only its bound resource and cannot call other APIs or download another file.

Business Writes ​

Write endpoints follow the same order:

  1. Validate input and permissions.
  2. Mutate business data inside a database transaction.
  3. Synchronize EMQX or dispatch MQTT when required.
  4. Publish SSE refresh events.
  5. Return a result that the frontend can display or use to refresh projections.

When an external system is unavailable, database semantics should remain explicit: persist operations that are safe to persist, and return a clear business error when consistency cannot be guaranteed.

Authentication API ​

MethodPathDescription
GET/api/v1/auth/stateRead setup and current-session state.
POST/api/v1/auth/setupInitialize the administrator password.
POST/api/v1/auth/loginSign in and return a Bearer token.
GET/api/v1/auth/sessionValidate the current Bearer token.
POST/api/v1/auth/logoutFrontend logout endpoint.
POST/api/v1/auth/passwordChange the administrator password.

Config API ​

MethodPathDescription
GET/api/v1/configsList configs.
POST/api/v1/configsCreate a config.
GET/api/v1/configs/{config_id}Read a config.
PUT/api/v1/configs/{config_id}Update a config.
DELETE/api/v1/configs/{config_id}Delete a config.
GET/api/v1/configs/{config_id}/overviewRead the config overview projection.
POST/api/v1/configs/awg/randomGenerate config-level AmneziaWG parameters.
POST/api/v1/configs/awg/generateGenerate shared and endpoint drafts without database access or MQTT.
GET/api/v1/configs/protocol-optionsRead AWG versions, the default version, and per-version parameter capabilities.
POST/api/v1/configs/awg/convertPrefill an AWG draft for the target version; extensions include only supported fields and randomization strategy, without database writes.

AWG config writes use tunnel_protocol=amneziawg and awg_version=1.5/2.0/3.1. Selecting AWG for the first time requires a version. The API also accepts tunnel_protocol=amneziawg_2, parsed as AWG 2.0. Config and endpoint extensions use awg_options. Conversion accepts current parameters, source_version (nullable), and the target awg_version. Config update responses include adjustments describing backend-adjusted fields.

Config-level and endpoint-level /awg/random endpoints accept an awg_version query parameter, defaulting to 2.0. Config randomization normally generates S/H only; regenerate_key=true generates the shared 3.1 key separately. MCP writes follow the same version and parameter rules.

Unified generation uses POST /configs/awg/generate with awg_version, direction (generic/dns/stun/rtp/quic), intensity (low/balanced/high), current config parameters, and nodes (endpoint ID → current AWG parameters). It returns {config, nodes} for editing only. Config updates accept awg_node_updates (endpoint ID → J/I and awg_options), written atomically with shared parameters. IDs outside the config and non-AWG endpoint fields are rejected. Cleared I values are omitted, not randomly refilled. The frontend discards unsaved endpoint drafts when changing version. Pages use this endpoint for random generation.

Endpoint API ​

The generation endpoint also accepts scope=node (default all), requiring exactly one endpoint in nodes. Existing shared parameters are validated without generating S/H, shared keys, or changing mechanism switches. Response config only echoes validated shared parameters. The endpoint page uses only the returned node draft and saves through PUT /api/v1/nodes/{node_id}.

MethodPathDescription
GET/api/v1/configs/{config_id}/nodesList endpoints in a config.
POST/api/v1/configs/{config_id}/nodesCreate an endpoint.
GET/api/v1/nodes/{node_id}Read an endpoint.
PUT/api/v1/nodes/{node_id}Update an endpoint.
DELETE/api/v1/nodes/{node_id}Delete an endpoint.
POST/api/v1/configs/{config_id}/nodes/suggest-ipSuggest a virtual IP.
POST/api/v1/configs/{config_id}/nodes/validate-ipValidate a virtual IP.
POST/api/v1/nodes/keys/generateGenerate a WireGuard key pair.
POST/api/v1/nodes/keys/derive-publicDerive a public key from a private key.
POST/api/v1/nodes/awg/randomGenerate endpoint-level AmneziaWG parameters.

Tag API ​

MethodPathDescription
GET/api/v1/configs/{config_id}/tagsList tags and counts.
POST/api/v1/configs/{config_id}/tagsCreate a tag.
POST/api/v1/configs/{config_id}/tags/applyApply a tag to multiple endpoints.
DELETE/api/v1/configs/{config_id}/tags/{tag_name}Delete a config-level tag.
PUT/api/v1/nodes/{node_id}/tagsReplace endpoint tags.
DELETE/api/v1/nodes/{node_id}/tags/{tag_name}Remove a tag from an endpoint.

Mesh API ​

MethodPathDescription
GET/api/v1/configs/{config_id}/peer-linksList Mesh pairs.
GET/api/v1/configs/{config_id}/nodes/{node_id}/mesh-workspaceRead an endpoint Mesh workspace.
GET/api/v1/configs/{config_id}/nodes/{node_id}/peer-link-draftBuild a Mesh pair draft.
POST/api/v1/configs/{config_id}/peer-linksCreate a bidirectional Mesh pair.
PUT/api/v1/peer-links/{group_id}Update a bidirectional Mesh pair.
DELETE/api/v1/peer-links/{group_id}Delete a bidirectional Mesh pair.
POST/api/v1/peer-links/psk/generateGenerate a PSK.
POST/api/v1/configs/{config_id}/mesh/validateValidate the Mesh topology.
POST/api/v1/configs/{config_id}/mesh/quick-generateDelete and regenerate Mesh pairs using Quick Mesh.
GET/api/v1/configs/{config_id}/nodes/{node_id}/wg-previewPreview the generated WG/AWG config.

When updating a Mesh pair, forward and reverse are matched to existing records by their local_node_id and peer_node_id, so either endpoint can edit the pair. The two directions must be opposites and refer to the existing pair's endpoints; otherwise, the API returns INVALID_PEER_LINK.

Config Apply and Endpoint Control API ​

MethodPathDescription
GET/api/v1/configs/{config_id}/sync-statusRead sync states for all endpoints in a config.
GET/api/v1/configs/{config_id}/nodes/{node_id}/sync-statusRead one endpoint sync state.
GET/api/v1/configs/{config_id}/nodes/{node_id}/applied-confRead applied config text.
PUT/api/v1/configs/{config_id}/nodes/{node_id}/applied-confSave applied config text.
POST/api/v1/configs/{config_id}/nodes/{node_id}/syncSync one endpoint.
POST/api/v1/configs/{config_id}/sync-allSync all eligible endpoints in a config.
GET/api/v1/configs/{config_id}/endpoint/runtime-snapshotRead the runtime snapshot.
GET/api/v1/configs/{config_id}/nodes/{node_id}/endpoint/statusRead endpoint runtime status.
POST/api/v1/configs/{config_id}/nodes/{node_id}/bind-commandCreate a client bind command.
POST/api/v1/configs/{config_id}/nodes/{node_id}/reset-clientReset client binding and MQTT credentials.
GET/api/v1/configs/{config_id}/nodes/{node_id}/endpoint/logsRead endpoint control logs.
POST/api/v1/configs/{config_id}/nodes/{node_id}/endpoint/controlSend start, stop, push_config, or wg_show.
POST/api/v1/configs/{config_id}/endpoint/probe-batchProbe endpoints in a batch.

Tools API ​

MethodPathDescription
GET/api/v1/tools/download/client-optionsRead client build options.
POST/api/v1/tools/download/client-artifacts/buildBuild or locate a client artifact.
POST/api/v1/tools/download/client-artifacts/download-grantCreate a five-minute single-file token for a local-build client artifact; Release artifacts do not use this endpoint.
GET/api/v1/tools/download/client-artifacts/{artifact_id}Download a client artifact.
GET/api/v1/tools/download/config-bulk/optionsRead bulk config download options.
POST/api/v1/tools/download/config-bulk/packageCreate a bulk config package.
GET/api/v1/tools/download/config-bulk/package/{package_id}Download a bulk config package.
GET/api/v1/tools/port-forwards/configs/{config_id}List port-forward rules.
POST/api/v1/tools/port-forwards/configs/{config_id}Create a port-forward rule.
PUT/api/v1/tools/port-forwards/{rule_id}/enabledEnable or disable a port-forward rule.
DELETE/api/v1/tools/port-forwards/{rule_id}Delete a port-forward rule.

Backup API ​

MethodPathDescription
POST/api/v1/backups/snapshotCreate a snapshot.
GET/api/v1/backups/listList snapshots.
GET/api/v1/backups/download/{snapshot_id}Download a snapshot.
GET/api/v1/backups/export/{snapshot_id}Export a snapshot.
POST/api/v1/backups/restore/{snapshot_id}Restore a snapshot.
POST/api/v1/backups/uploadUpload and import a snapshot.
POST/api/v1/backups/importUpload and import a snapshot.
DELETE/api/v1/backups/{snapshot_id}Delete a snapshot.
PUT/api/v1/backups/{snapshot_id}/noteUpdate a snapshot note.

Settings and System API ​

MethodPathDescription
GET/api/v1/settings/uiRead UI settings.
PUT/api/v1/settings/uiUpdate UI settings.
GET/api/v1/settings/mqttRead the client-facing MQTT address.
PUT/api/v1/settings/mqttUpdate the client-facing MQTT address.
POST/api/v1/settings/mqtt/resetReset MQTT settings to environment defaults.
POST/api/v1/settings/mqtt/testTest MQTT access settings.
POST/api/v1/settings/passwordChange the administrator password.
GET/api/v1/system/healthHealth check.
GET/api/v1/system/timezoneRead the configured timezone.
GET/api/v1/system/statusRead system status.
GET/api/v1/events/streamSSE realtime event stream.

Client and Internal API ​

MethodPathDescription
POST/api/client/v1/bindExchange a bind token for a profile, MQTT credentials, and config.
POST/api/client/v1/update/checkRead the server version and supported target using node credentials.
POST/api/client/v1/update/artifactRequest exact-version GitHub package metadata or a server-built artifact and short-lived download grant.
POST/api/internal/emqx/authzInternal-only EMQX HTTP AuthZ callback.
POST/api/v0/dev/reset-bootstrapDev/test endpoint registered only when WFM_ENABLE_DEV_TEST_API=true.

Update endpoints use HTTP Basic with an existing binding's MQTT username and password. The configuration and dynamic node must be valid, enabled, and bound. Both requests contain config_id, node_id, goos, and goarch; artifact also contains version and source (github_release or local_build). check never builds. A changed version returns CLIENT_UPDATE_VERSION_CHANGED (409); invalid credentials return CLIENT_UPDATE_UNAUTHORIZED (401). Local builds reuse the target allowlist, build locks, and cache, accepting no arbitrary command, source path, or version.

Page-scoped runtime observations ​

POST /api/v1/configs/{config_id}/runtime-watch requires an administrator session. Fields are viewer_id (1–64 letters, digits, or hyphens), optional node_id, mesh, and active. Visible pages renew every 30 seconds; the server merges collection demand. active=false releases the registration for that config. No command arguments are accepted.

Endpoint projections expose endpoint_state: offline, not_started, or online. The underlying online field still means client reachability. Static nodes do not show client runtime status.

Each Mesh workspace connection exposes health: state is healthy, interrupted, or null when both nodes are static. reason explains the decision and observations identifies sources and data. A recorded handshake does not guarantee current reachability of all business addresses.

The endpoint control action wg_show accepts optional strict boolean current_interface_only. Other actions reject this option; unconfirmed client capability returns CLIENT_OBSERVATION_UNSUPPORTED.

Config counters follow endpoint display states: online_node_count counts dynamic nodes with confirmed running interfaces, offline_node_count counts unreachable clients, and not_started_node_count counts reachable clients without a confirmed running interface.

Config topology board ​

GET /api/v1/configs/{config_id}/topology is a session-protected, read-only endpoint returning config, nodes, connections, issues, and generated_at. Missing configs return 404.

Nodes include isolated and disabled endpoints. Each valid two-node connection group appears once under its group UUID; node UUIDs provide stable source/target ordering. Each direction retains its actual local_node_id/peer_node_id, independent of names or array order. Missing directions are null; malformed groups appear in issues.

Health uses the existing Mesh rules while retaining observations from both ends. Explicit field allowlists exclude private keys, plaintext PSKs, and AWG secrets. To observe an entire config, renew runtime-watch with mesh=true and no node_id. The GET itself never starts collection.

Each connection includes a server-provided validation_errors list covering duplicate enabled pairs, invalid direction structure, and existing Mesh validation rules. An empty list means no validation errors. This field is independent of runtime health; static connections are also validated. The frontend gives validation errors priority using red lines.