MQTT client management API (Mgmt add-on)
Automate portal MQTT clients (broker credentials that may publish, subscribe, or both) with the Mgmt REST API add-on.
Portal concepts and ACLs: MQTT clients. HTTP paths still use /api/v1/subscriber/publishers for compatibility.
Before you start
- Enable Mgmt REST API under Subscriptions in the portal.
- Create a REST API token in Settings — see REST API tokens.
- Use OpenAPI at
/api/v1/subscriber/docson your portal host.
Every request:
List MQTT clients
Each row includes client_id, topic (MQTT pattern hint), and pause state. Passwords are not returned from list.
Create an MQTT client
curl -sS -X POST "${PORTAL_ORIGIN}/api/v1/subscriber/publishers" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{"label":"site-alpha-sensor","allow_subscribe":true}'
The create response includes device.password and publish_topic. Copy the password before you close the terminal — it is not returned on list or get.
History / Flux / REST always use the account-first platform path (UUID tenant id as the first topic segment):
List responses include history_topic_prefix with that prefix for each device. The topic field is a live MQTT pattern hint (may differ for auto-enrolled vendor devices). For stored data and Grafana, use history_topic_prefix. Setup: MQTT clients — platform layout.
Pause, resume, remove
CLIENT_ID="pub-..."
curl -sS -X POST "${PORTAL_ORIGIN}/api/v1/subscriber/publishers/${CLIENT_ID}/pause" \
-H "Authorization: Bearer ${TOKEN}"
curl -sS -X POST "${PORTAL_ORIGIN}/api/v1/subscriber/publishers/${CLIENT_ID}/resume" \
-H "Authorization: Bearer ${TOKEN}"
curl -sS -X DELETE "${PORTAL_ORIGIN}/api/v1/subscriber/publishers/${CLIENT_ID}" \
-H "Authorization: Bearer ${TOKEN}"
Rotate MQTT password
curl -sS -X POST "${PORTAL_ORIGIN}/api/v1/subscriber/publishers/${CLIENT_ID}/rotate-credentials" \
-H "Authorization: Bearer ${TOKEN}"
Returns a new MQTT password in the response body. Copy it immediately; it is not shown again.
Read-only subscribers (listen)
To subscribe on {account_id}/# only (no device publish on vendor paths), use the separate read-only subscriber API — same Mgmt add-on and REST token: